Accessing a BinarySearchTree from a button

Hello I am trying to figure out how to check to see if a certain value is in my BinarySearchTree. I get the value from a Jtextfield and then I can't access my BST from the actionlistner method. here is a snib of my code
//In with the rest of my GUI code
class ButtonHandler implements ActionListener
public void actionPerformed( ActionEvent e )
String cmd = e.getActionCommand();
String lastName;
if( cmd.equals( "Find" ) )
lastName = txtLastName.getText();
//Here I would check to see if last name was in my BST, but i can not Access it.
public static void main(String[] args)
BinarySearchTree bst = new BinarySearchTree();
File dataFile = new File("datafile.txt");
if(dataFile.exists())
loadBST(bst);
Project2 app = new Project2();
app.setVisible( true );
public static void loadBST(BinarySearchTree bst)
String fileLine;
String[] data;
Person[] people = new Person[300];
int i = 0;
try
BufferedReader br = new BufferedReader(new FileReader("datafile.txt"));
while( ( fileLine = br.readLine() ) != null)
data = fileLine.split("\t");
Person person = new Person( data[0], data[1], data[2], data[3], data[4].charAt(0), data[5]);
people += person;+
bst.add( data[0], i );
i+;+
+}+
br.close();
+}+
catch( IOException e )
+{+
System.out.println("Could not Read the data file.");
+}+
+}+
+}+
+I have a BST class with a find method that is looking for a String, but i dunno how to access it from my action listener? I have tried declaring my BST with all of my GUI declaration but then i would be tring to reference a Non-static variable in a static method. I am not sure how to do this.
Edited by: Capt. on Mar 20, 2008 4:21 AM
Edited by: Capt. on Mar 20, 2008 4:24 AM

Well, unfortunately I must keep my load static class. If I declare like this..
public class Project2 extends JFrame
private JTextField txtLastName, txtFirstName, txtSSN, txtPhone, txtBirthDate;
private JButton btnFind, btnAdd, btnDelete, btnExit;
private JRadioButton radMale, radFemale, radDummy;
private BinarySearchTree bst = new BinarySearchTree();
public Project2( )
setTitle( "BSTDataBase" );
setSize( 300, 300 );
setLocationRelativeTo( null );
Is there a way to access that variable anywhere since it would be a class variable now, such as in the main or action listener methods? I think I heard something about ap.tree or something like that, dont know how to use it or the proper syntax though.

Similar Messages

  • ADF - Accessing view object from a button in a window

    Hi
    I am using Jdeveloper 10.1.3.2.0 to build a Swing/ADF application.
    I added a method to a view class to call a database procedure.
    I use that view as a base of a jTable to display data in a window.
    Now I need to call the method that I created in the view class from a button on the same window where I display the data, ideally using the same db connection.
    I am quite new to ADF and I have no idea how to get a reference to the view instance in the button method to call my new method. How can I do that? Is there another way to achieve this?
    Thanks!
    Luis

    You usually do this by creating the method at the application module level and then exposing it as a client method. You can then drag and drop it onto your form as a button.
    See details in the ADF Developer Guide chapters 8.3-8.5:
    http://download.oracle.com/docs/html/B25947_01/bcservices003.htm#sm0206

  • First time going to a site where I do not have access and clicking the back button I'm returned to the root site instead of the site I started from

    Greetings,
    I have SharePoint 2013 enterprise using ADFS for authentication.  I have an issue where the first time going to a site where you do not have access and clicking the back button you're returned to the root site instead of the site you
    started from.
    ie:
    1) at site http://www.sharepoint.com/sites/finance/home.aspx
    2) browse to
    http://www.sharepoint.com/sites/finance/private/home.aspx
    3) receive a message: you do not have access to this site  ((oops went to the wrong location - I'll hit the back button))
    4) click the browser back button
    5) get returned to http://www.sharepoint.com/pages/home.aspx
    This only happens the first time browsing to a site that I do not have rights to, after this I can browse to the same site and hit the browser back  button and return to the correct site, or any other site that I do not have access to.
    Any ideas as to why this happens?  Ideas of where to start looking?
    Thanks

    Hi Robert,
    From your description, when you receive access denied message and hit back button in browser, it redirects you to the root site but not previous site. However, this just happens at the first time.
    You may try to use some tool or check log which can tell us how does it handle the request when you hit the button. And compare the issue time and non-issue time.
    I'd suggest you use Netmon tool:
    http://blogs.msdn.com/b/carloshm/archive/2012/11/08/sharepoint-2013-network-monitor-parsers.aspx
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Treo 750 can't access programs list from start or windows button

    Hi first time question. I have treo 750 and just recently can't access any programs from windows or start button. Can't even access memory to delete unnecessary files. What to do?
    thanks Mike
    Post relates to: Treo 750 (AT&T)

    Is this a memory problem you are running into? Have you tried a soft reset?
    Post relates to: Palm Z22

  • How can i access and change a text from a button in diferents symbols!?

    I have this:   ELEMENTS:  Stage  - symbol_1
                                                         - symbol_2
    So,... i would like to change a text inside symbol_2 from a button on symbol_1, using sym.$("Text").html("NewText");  What's the correct path!?
    Thanks in advance,
    Regards,

    sym.$('symbol_2')
    sym.getComposition().getStage(). getSymbol('symbol_1').$("Text").html("NewText");

  • Access to MD03 from another transaction

    Hi Gurus,
    We did a trace to all the users, and one of them used the MD03 transaction. The point is that he has no authorization to this transaction, so probably he is accessing to it from another.
    Could you help me searching any transaction where the user could jump to MD03 from menu, buttons, double click,...?
    Thank you in advance.

    Hi,
    Click on Enviornment>>Navigation profile>>Assign. In the General settings tab page you can assign the navigation profile. Just check whether the navigation profile assigned to the user has the T-code MD03. Check the seetings and t-codes in OM0K - Define navigation profile.
    But as suggested by Mr.Brahmankar kindly check whether it's possible to access the transaction from MD04 if the user doesn't have the authorization of other transaction which he/she is accessing. In your case MD03. I'm not sure about that.
    Regards,
    Lodhi.S

  • Can't access my dvr from safari

    Hi,
    I have a problem with safari.  I can't access my dvr from the browser.
    After I sign in to my dvr webpage this message comes instead of loading java: The requested URL was not found on this server
    I have this message when I try with Mozilla:
    CacheEntry[http://xx.xxx.xx.xx/application.jar]: updateAvailable=false,lastModified=Thu Jan 01 01:00:00 CET 1970,length=40266
    Missing Application-Name manifest attribute for: http://xx.xxx.xx.xx/application.jar
    Missing Permissions manifest attribute in main jar: http://xx.xxx.xx.xx/application.jar
    java.io.FileNotFoundException: abc (Permission denied)
    Thanks in advance for any help you can provide!

    Sorry... I didn't realize that this problem was common, not rare.
    I remove the Discussion-related cookies and restarted. I did get to the sign-in page this time, but after clicking the sign-in button, I got "An Internal Server Error Has Occurred." (Nothing else on the page.)
    I decided to check cookies again, and the same ones that I eliminated were back again. Needless to say, repeating the exercise didn't work.
    Resetting Safari is out of the question. I have years worth of settings and cookies stored there for a good reason, and I'm not going to start over from scratch. I can't imagine why anyone would, unless they have a whole lot of time on their hands.
    So... I've decided that this is Apple's problem. If I need Apple Discussions I'll use a browser that works.. which apparently is every browser except Safari. Now that's ironic!

  • (ATV2 tv) can't access rented show from my favorites.

    (ATV2 tv) can't access rented show from my favorites. Error is "The iTunes store is currently unavailable. Try again Later." I have updated and rebooted ATV, as well as my router a number of times. I don't want to rent it again, any ideas?

    Thank you! Knowing someone else had the issue helped me fix it on my end!
    I'm guessing it's a server issue of some sorts.. maybe just some accounts. It's not the first time favorites has been broken, last time it was broken I just couldn't enter the favorites area. The spinny thing just appeared forever.
    My fix: though nothing in favorites works (every time I press select on the show I want it displays the same error as you get), from the main menu with the TV shows menu open, but favorites not yet entered, press the up button and it'll move the cursor to the first image in the menu of rentals at the top of the screen. Easier anyway! Didn't know you could!
    On top of that, though I'm now unable to rent via favorites itself, I can do so via the "top tv rentals" thing.
    Hope this helps and they fix it soon! :/

  • Access main stage from a symbol timeline?

    Can I access main stage  from a symbol timeline?
    Eg:
    I have a symbol called "ball" and its own time line. There is a close button at the end of ball's timeline,
    When close button pressed, I want to go back to main timeline.
    Thanks
    Phyle

    Thanks Hemanth.  I will try to explain.
    Open Edge animate. On the main stage I added a label called "home".
    I created circle, converted to symbol, renamed to "ball".
    Inside "ball" , I have a animation, at the end there is a button called "closeBt"
    When "closeBt" pressed, I want to go back to main stage "home"

  • I cannot access my mail from my ipad. I keep getting an error message "MFMessageErrorDomain error 1032". Does anyone know how to fix this?

    I cannot access my mail from my ipad. I keep getting an error message "MFMessageErrorDomain error 1032"

    iOS: Unable to send or receive email
    http://support.apple.com/kb/TS3899
    Can’t Send Emails on iPad – Troubleshooting Steps
    http://ipadhelp.com/ipad-help/ipad-cant-send-emails-troubleshooting-steps/
    Setting up and troubleshooting Mail
    http://www.apple.com/support/ipad/assistant/mail/
    Server does not allow relaying email error, fix
    http://appletoolbox.com/2012/01/server-does-not-allow-relaying-email-error-fix/
    Why Does My iPad Say "Cannot Connect to Server"?
    http://www.ehow.co.uk/info_8693415_ipad-say-cannot-connect-server.html
    iOS: 'Mailbox Locked', account is in use on another device, or prompt to re-enter POP3 password
    http://support.apple.com/kb/ts2621
    iPad Mail
    http://www.apple.com/support/ipad/mail/
    Configuration problems with IMAP e-mail on iOS with a non-standard SSL port.
    http://colinrobbins.me/2013/02/09/configuration-problems-with-imap-e-mail-on-ios -with-a-non-standard-ssl-port/
    Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
    Or this - Delete the account in Mail and then set it up again. Settings->Mail, Contacts, Calendars -> Accounts   Tap on the Account, then on the red button that says Remove Account.
     Cheers, Tom
    Tap Settings > Mail, Contacts, Calendar and delete your email account.
    Then tap Settings > Safari > and Tap Clear History and Clear Cookies and Data.
    Now tap Settings > Mail, Contacts, Calendar and re-enter your email account credentials.
    Message was edited by: Texas Mac Man

  • Geting a name from a button I just pressed

    Hi !
    I tried to use this._name to get the name on a button in one
    of my movieclips. but that just gives me the name of the movieclip.
    I tried to access the name from within the button but I can't post
    any scripts in the buttons scriptpanel. how will I get the name
    otherwise?
    /Mikael

    Define it as a function instead of adding the handler
    directly to the
    button. If your buttons instance name is btnOne then place
    this on the
    timeline of the clip it's contained in:
    btnOne.onRelease = function(){
    trace(this._name);
    Dave -
    Head Developer
    www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • How to access PC files from iPad

    How can I access PC files from my iPad?

    Depends on what kind of files. You have to have an app on your ipad that can open those files and share them.
    You can download the icloud control panel and use that on your pc.
    http://www.apple.com/icloud/setup/
    itunes also supports file sharing:
    To transfer files from your computer to your iPod touch, iPhone, or iPad:
    Connect your iPod touch, iPhone, or iPad to your computer.
    In iTunes, select your device (below Devices), and click the Apps button.
    Below File Sharing, select an app from the list, and click Add.
    In the window that appears, select a file to transfer, and click Choose.
    The file is transferred to your device, and can be opened in the app you selected in step 3.

  • Mac book pro needs to force shut down from power button after upgrading lion.

    I had upgraded my mac book pro to os x lion from snowleopard but on 2 days while i was suttig down i waits 10 -15 seconds that it says that i had to force shut from power button . this is really bugging me . what could be the problem ???
    Than you for your answers.

    I had the same new feature with Lion on my iMac 24".
    try to repair access privilegs.
    Try Resetting the PRAM
    If that doesn't help, try Resetting the SMC

  • How to access next record from database on to form

    hi
    i have written the following piece of code to retrieve data from database oon to form...
    Try
                rset = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                query = "Select * from [@TEST]  where Code =  ('" + oform.Items.Item("6").Specific.value + "') "
                rset.DoQuery(query)
            Catch ex As Exception
                SBO_Application.MessageBox(ErrorToString)
            End Try
            '  oform.Items.Item("6").Specific.value = rset.Fields.Item("Code").Value
            oform.Items.Item("7").Specific.value = rset.Fields.Item("Name").Value
            oform.Items.Item("8").Specific.value = rset.Fields.Item("U_Sal").Value
    but i can see only one record on my form controls.... i have placed on more button called " Next" so that i can access next records from DB when i click on "Next" button...
    Public Sub NextRecords()
    Try
         rset.MoveFirst()
                While Not rset.EoF
                 '   oform.Items.Item("6").Specific.value = rset.Fields.Item("Code").Value
                   oform.Items.Item("7").Specific.value = rset.Fields.Item("Name").Value
                  oform.Items.Item("8").Specific.value = rset.Fields.Item("U_Sal").Value
                   rset.MoveNext()
                End While
                rset.MoveNext()
          Catch ex As Exception
               SBO_Application.MessageBox(ErrorToString)
          SBO_Application.MessageBox("Updated")
           End Try
    End sub
    i'm not able to access next records...
    plz provide me the solution and code for this how to handle this scenario....

    From your question and code sample given, I think the problem is you are seeing only the last record when pressing the next button.
    In the Next button press, you are coded such a way that it will populate the last record.
    Try removing the do..While.. loop and simply code like
    if Not rset.EoF
    rset.MoveNext()
       oform.Items.Item("6").Specific.value = rset.Fields.Item("Code").Value
       oform.Items.Item("7").Specific.value = rset.Fields.Item("Name").Value
       oform.Items.Item("8").Specific.value = rset.Fields.Item("U_Sal").Value
    end if
    So when you click next, you can see the next record. Not the last record.
    Anoop

  • Can't access my iMac from a Windows 98 PC

    When I was prompted for password on the PC running Win 98, I simply clicked "OK" as I had not set any user password on my iMac. However, I got the "wrong password" message and therefore failed to access my iMac from that PC.
    On the PC, I could ping the iMac without problems. I can also access the PC from my iMac. I have the username on the PC that is exactly the same as the one I have enable "Windows Sharing".
    Any clues on this?

    Thanks James.
    I tried but without luck. The issue is, it prompts me for password and whatever I input, it says wrong password. In fact, I do not have any password set on my iMac and therefore I should be let through if I simply click the "OK" button on the password dialog without putting anything in the password field.

Maybe you are looking for

  • Multiple Libraries in iTunes 7 (Windows)

    Another whinge about iTunes 7! The multiple libraries feature in the Windows version (I don't know about the Mac version) is very poorly implemented and, quite frankly, useless. When changing libraries in iTunes 7, the preferences for the new library

  • Memory card password request after software upgrad...

    Nokia 6700 Requesting Memory card password? I have a Nokia 6700 Classic, the bluetooth stopped working so I called Orange who checked I was following the instructions clearly and then suggested I download the latest software version 13.20  via the co

  • Menu map for 6070

    Hi. I'm looking for the Manu map for Nokia 6070 My problem is that the display of the phone is broken, It doesn't show anything, but otherwise the phone works well, I can call, or recieve calls. Before I take it to repair, I would like to connect to

  • MuVo TX SE Playlist order probl

    I create a playlist in Windows Media Player in a very specific order (I am a dance teacher and need to have a specific order and play non-stop for dance routines etc). The playlist needs to be independent of album and artist name. When the created pl

  • Time change in U.S.

    Daylight saving time resumes at 2 a.m. Sunday. Clocks move ahead an hour. Will the iPhone update its clock at that time by itself, or does it have to get the new time from the AT&T network? More specifically, if I set the alarm on my phone to go off