How can i get a component from frame?

how can i get a JTextField component from the frame?
in my program i use button and text fields, when button is pressed the action listener performs the needed actions: it must take the values in the text fields and do something with them,
for example i have a button - view:
look at the comments
public class _ActionListener_search implements ActionListener {
     private JFrame frame;
     private database dtbs;
     public _ActionListener_search(JFrame frame, database dtbs) {
          this.frame = frame;
          this.dtbs = dtbs;
     @Override
     public void actionPerformed(ActionEvent arg0) {
          if (arg0.getActionCommand().equals("view_person"))
                                        //HERE i want to get values from text fields!
                                        //i need to get JTextField component from frame and use it
view.addActionListener(new _ActionListener_search(frame, dtbs));how can i do it?
is this a correct way?

Encephalopathic wrote:
If you know that you're going to need the data held in them why not give the class that holds them a public method that returns the Strings that they hold.
public String getTextFieldXyzText()
return textFieldXyz.getText();
}Then if your actionlistener has a reference to this class's object, it can simply call the above method.That's what I was thinking. The view has a method getXyzText() and the listener (or some larger, enclosing controller) knows the view.
What I would get away from is a single, switch-board listener hooked to a 100 unrelated buttons.

Similar Messages

  • How can I get the events from a java program?

    I want to make a monitor to watch a java program.How can I get the events from the GUI of this program some as mouse cliking, keyinput. So I can watch these in my monitor.
    Thanks

    Hi,
    To put a monitor to the events occuring in the GHUI u need to register required components with the appropriate EventListeners.
    Liek if u want to get notified when a mouse is clicked, then u need to add The MouseListener to the component which u want to be monitored.
    Say
    myFrame which is the JFrame object which shuld be monitored for the events.
    Then in ur program u have to add following code
    myFrame.addMouseListener( someObectReference );
    Here the someObjectReference should be an instance to a concrete class ..i.e. U write a class like the following
    public class MyMouseListener implements MouseListener {
    // override the followig methods
    public void mouseClicked(MouseEvent me){ sop("MOUSE CLICKED ON THE FRAME");}
    public void mousePressed(MouseEvent me){}
    public void mouseReleased(MouseEvent me){}
    If u dont want to use another class for listening to the events. Then u can make teh current class monitor the events. To do so ur class should implement the appropriate listener and should override the required methods.
    and u should say myFrame.addMouseListenet( this );
    thats it

  • I have Point, how can I get the component of this Point?

    Hi, everybody!
    Can U help me!
    I have 10 block in 1 applet. After 1 even, I kept the Point of the block, just made even. I want remove the block, which have the point. Then I use method getComponentAt() but I can't.
    Anyone tell me the way to process.
    Agains, I have the Point, how can I get the component of this Point?
    Thanks so much!

    That makes no difference, as you can still use this method with AWT.
    // parent is you main Frame or Dialog window.
    Component parent;
    // target is the AWT component that the user has clicked on.
    Component target;
    // "e" is is your click event.
    MouseEvent e;
    target = SwingUtilities.getDeepestComponentAt(parent, e.getX(), e.getY());

  • How can i get all values from jtable with out selecting?

    i have one input table and two output tables (name it as output1, output2). Selected rows from input table are displayed in output1 table. The data in output1 table is temporary(means the dat wont store in database just for display purpose).
    Actually what i want is how can i get all values from output1 table to output2 table with out selecting the data in output1 table?
    thanks in advance.
    raja

    You could set the table's data model to be the same:
    output2.setModel( output1.getModel() );

  • How can i get thes songs from ipod nano to the itunes libary??

    hi
    i have ipod nano and i sync it with over 500 songs .....my bad i lose all that songs on my libary  .... how can i get thes songs from ipod nano to the itunes libary??

    See this older post from another forum member Zevoneer on different ways to copy content from your iPod to your computer.
    https://discussions.apple.com/thread/2452022?start=0&tstart=0
    B-rock

  • How can I get all photos from iPhoto to automatically back up to iCloud from my Mac OSX Version 10.6.8 operating system.  Not enough memory to upgrade.

    How can I get all photos from iPhoto to automatically back up to iCloud from my Mac OSX Version 10.6.8 operating system.  Not enough memory to upgrade.

    You can't.  iCloud is not for general file backup from a Mac. It's for backup up and syncing data between mobile devices and and Macs and  The following is from this Apple document: iCloud: Backup and restore overview.
    iCloud automatically backs up the most important data on your (mobile) device using iOS 5 or later. Once you have enabled Backup on your iPhone, iPad, or iPod touch .....
    What is backed up
    You get unlimited free storage for:
    Purchased music, movies, TV shows, apps, and books
    Notes: Backup of purchased music is not available in all countries. Backups of purchased movies and TV shows are U.S. only. Previous purchases may not be restored if they are no longer in the iTunes Store, App Store, or iBookstore.
    Some previously purchased movies may not be available in iTunes in the Cloud. These movies will indicate that they are not available in iTunes in the Cloud on their product details page in the iTunes Store. Previous purchases may be unavailable if they have been refunded or are no longer available in the iTunes Store, App Store, or iBookstore.
    You get 5 GB of free iCloud storage for:
    Photos and videos in the Camera Roll
    Device settings (for example: Phone Favorites, Wallpaper, and Mail, Contacts, Calendar accounts)
    App data
    Home screen and app organization
    Messages (iMessage, SMS, and MMS)
    Ringtones
    Visual Voicemails
    But not from a Mac.  If you want to backup your photos and other important files I suggest you get an external hard drive and use  it with Time Machine.
    OT

  • How can I get all photos from the camera roll onto the photo stream so they will share between iphone and ipad?

    How can I get all photos from the camera roll, and all new pictures taken, to get on the photostream so they can share between iphone and ipad?

    When turning PhotoStream on with photos available in the Camera Roll, only photos captured by the iPhone or saved on the iPhone are placed in the PhotoStream.
    For all photos that were in the Camera Roll prior to turning PhotoStream on, import the photos with your computer and add the photos to your PhotoStream on your computer.

  • I have an iPod Classic and the latest version of iTunes. I make all my purchases on my computer, but when I try to click the "add to" option and transfer the songs to my iPod, it doesn't work. How can I get my songs from my computer to my iPod?

    I have an iPod Classic and the latest version of iTunes. I make all my purchases on my computer, but when I try to click the "add to" option and transfer the songs to my iPod, it doesn't work. How can I get my songs from my computer to my iPod?

    See this excellent user tip from another forum member turingtest2 outlining the different methods and software available to help you copy content from your iPod back to your PC and into iTunes.
    Recovering your iTunes library from your iPod or iOS device
    B-rock

  • HT4437 I want to develop a software with AirPaly service for business things. How can I get the permission from Apple?

    I want to develop a software with AirPaly service for business things. How can I get the permission from Apple?
    This one is used in Windows laptop, and I want it support AirPlay service, but Apple doesn't publish the AirPlay protocol.
    Many thanks.

    Create a developer account, then access he developers forums and see if you can find the information that way 
    The other option would be to simply contact Apple directly.

  • How can i get a pdf from my iPhone to my new macbook? I keep trying to sync but it says it will delete all the books/pdfs on my phone. I don't have this pdf on my computer and don't want to lose it. Help please!

    How can i get a pdf from my iPhone to my new macbook? I keep trying to sync but it says it will delete all the books/pdfs on my phone. I don't have this pdf on my computer and don't want to lose it. I am using the same iTunes account. Any suggestions?

    Hello ashlyn888,
    Based on your post it sounds like you would like to sync your iBooks content with your computer. I have located an article that may help you in this situation. While you can sync this data with your computer you can also use the sharing button to send PDFs using various sources:
    iBooks: Viewing, syncing, saving, and printing PDFs on iPhone, iPad, and iPod touch - Apple Support
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

  • My wife has an I Tunes account on our PC, I have an I tune account on my Mac Book Pro.   How can I get the music from her account on the PC to my account on the Mac Book and I phone?

    My wife has an I Tunes account on our PC, I have an I tune account on my Mac Book Pro.   How can I get the music from her account on the PC to my account on the Mac Book and I phone?

    IflyDavie wrote:
    I need help to delete my icloud account from my iPad.  It has "Find my iPad" on it and won't let me delete without the old password.  I don't want to reset password as it will require reset of Mac Book Pro and 2 iphones.  Help appreciated.
    Your description of the problem is a bit confusing.  Do you have ONLY ONE Apple ID or do you have MORE THAN ONE?

  • How can I get an invoice from the Apple store note that the original invoice may be burned with the house though Bamkmkm Send to Olga miles is my new (email address removed)and Thanks

    how can i get an invocce from the Apple store UK ?
    Message was edited by: Host

    Find the Apple Customer Support phone number for whichever country you're in and call them for assistance.

  • Can anyone let me know how can i get the ouput from BW in .txt format.

    Can anyone let me know how can i get the ouput from BW in .txt format. See we can get output as Excel(i.e BEX) and manually convert it into txt format. I need a direct or automated way to do the same.no human intervention.
    mail me at [email protected] or post answer in sdn.

    Please do not multiple post across forums..
    how can i save the data in BEX reports in .txt format automatically
    This helps in keeping track of answers and avoids the issue of repeated answers across forums...
    Please close one of the threads as answered and provide the link that you want to follow
    Arun

  • How Can we get the data from Non-SAP to SAP in WebDynpro

    Hi,
    I hope u understand my query, How can we get the data from Non-SAP to SAP thru WebDynpro Programming.
    Help out with the steps for getting the data or procedure.
    Regards,
    Mutyapu

    You can expose the APIs in the Non-SAP backend as Web Services, and consume them in SAP by creating an Enterprise Proxy. Then these can be called just like normal class methods from Web Dynpro.
    Regards,
    Nithya

  • How can I get a refund from an App that I bought?

    How can I get a refund from an app that I bought? I bought an app called Package for MS Office on the 8th of January and I also reported a problem and they have not got back to me with a response. It has been 3 weeks now and I am still waiting for a reply back. Very disappointed.

    I have now got an openoffice which I got from the internet. But the main thing is I paid £20.99 for this app and It is irriatting that the people who work for apple havent got back to me when I first reported a problem. I reported to them again and hoping that they will eventually get back to me.

Maybe you are looking for

  • IPhoto '08: How can I copy an album or slide show to another computer?

    Hi, I want to take a slideshow of a trip that I put music to and move it from my iBook to my new iMac so I can use iDVD to make a DVD of the slideshow (since I can't burn DVDs on my iBook). I have TONS of pictures from this trip, so it would really b

  • My ipod won't open the apps when i click on them?

    My ipod won't open the apps when i click on them, i've restarted my ipod multiple of time, closed everything that's open, and they are still not working, but i get the notifications through, please help!

  • SOAP sync to JMS async

    Hi Everyone, I'm trying to create the following scenario in SAP PI 7.31 but after a lot of thinking I do not see how I can create it in PI. I have JMS queues and topics where messages are stored. I need to make a soap call from a client app to PI to

  • Saving a half filled out form?

    I was planning to use LiveCycle to develop a long dynamic form for my company but after a couple of days of working with it I realized on my finished 'test' form that it could not be saved half way through the process (or at least that's what the rea

  • Blurry images when printed from indesign

    having problems with only some images in an indesign document. all images are placed and the original files are perfectly crisp pdfs...tried changing the display performance but still appearing and printing blurry? when i click f8 on the image it doe