Update Textfield between 2 jFrames

Hi,
I'm new to java and struggle to get my head around the following problem:
I've got a main frame (frame 1) where the user can press a button to display a seperate data selection frame (frame 2). Once the user made his selection I need to update textfields on the frame 1 with that information.
Currently I got one class in frame one declared as public static so I can write data from the second frame into that classes properties.
How can I tell frame 1 that the user has mad his selection (frame 2 is hidden again) so I can update textfields on frame 1 with the information stored in the class?
Is that done via an event listener? Can I create an event listener in frame 1 'listening' for the hide event of frame 2? If yes how does the code for that looks like?
Thanks!!!

Hi MelGohan,
thanks for the reply! I" think I'm almost there :-))
in form 1 this is the event handler for the button showing form 2
private void jBtnSelectGPActionPerformed(java.awt.event.ActionEvent evt) {
//window classes
JFrame SelectGP = new SelectGPForm(this);
//show gp select window
SelectGP.setVisible(true);
and this the method to update the text fields:
public void upDateGPTextFields (Address GPTest) {
//code
in form 2:
public SelectGPForm(JFrame Parent ) {
CallingFrame=Parent;
//code
there is an eventhandler in form 2 which looks after the ok button:
private void jBtnSelectGPOKActionPerformed(java.awt.event.ActionEvent evt) {
//call to form 1 method to update textfields here
So the parent frame reference gets transfered into the frame 2 constructor but how do I then use this in the event handler??
I declared a private variable in Form 2 (CallingFrame) to hold the parent frame reference so I can use it in the ok button event handler. But how exactly do I then access the calling frame methods??
Thanks!

Similar Messages

  • Problem updating textField via menuItem

    I am new to java and I am having a problem getting a menuItem to update a text field in my swing app. The following code is a striped down version but contains the necessary code to repeat my problem.
    I'm sure it is something fairly simple, but have had no luck finding a solution. All I want is for a menuItem to update the textfield once selected.
    How can I fix this?
    Please help.
    /*  this class test an implementation of JmenuItem and textfield
    where the menuItem is suppose to update the text in the textField*/
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MenuItemTest
        private GridBagLayout layout;
        private GridBagConstraints constraints;
        private JTextField termField;
        private JLabel headerLabel;
        private JLabel termLabel;
        private JMenuBar menuBar;
        private JMenu menu;
        private JMenuItem menuItem;
        public MenuItemTest()
            // create GUI components
            headerLabel = new JLabel("ItemMenu TextField Test");
            termLabel = new JLabel("Field:");
            termField = new JTextField("choose MenuItem");
        public Container createContentPane()
            //Create the content-pane-to-be.
            JPanel contentPane = new JPanel(new BorderLayout());
            contentPane.setOpaque(true);
            layout = new GridBagLayout();// new gridbaglayout
            JPanel p = new JPanel(layout); // set frame layout
            constraints = new GridBagConstraints(); // instantiate constraints
            // add components to JPane     
            setConstraints( 1,0,6,1,1,10);
            p.add(headerLabel,constraints);
            setConstraints( 2,1,1,1,1,2);
            p.add(termLabel,constraints);
            setConstraints(2,2,2,1,1,2);
            p.add(termField,constraints);
            contentPane.add(p, BorderLayout.CENTER);
            return contentPane;
        }// end createContentPane()
        // method for simplifying grabBagConstraints
        private void setConstraints(int row, int column, int width, int height,
                                    int fill, int ipady)
             constraints.gridx = column; // set gridx
             constraints.gridy = row; // set gridy
             constraints.gridwidth = width; // set gridwidth
             constraints.gridheight = height; // set gridheight
            constraints.insets = new Insets(1,1,0,0);//set uniform vertical gap
            constraints.fill = fill;
            constraints.ipady = ipady;
        }// end method addComponent
        //class for build menu bar
         public class MCalMenu
            public JMenuBar createMenuBar()
                //implements menu handler
                MenuHandler handler = new MenuHandler();
                //Create the menu bar.
                menuBar = new JMenuBar();
                menu = new JMenu("Menu");
                menuBar.add(menu);
                //a group of JMenuItems
                menuItem  = new JMenuItem("Preset Field 1");
                menuItem.addActionListener(handler);
                menu.add(menuItem);
                menuItem = new JMenuItem("Preset Field 2");
                menuItem.addActionListener(handler);
                menu.add(menuItem);
                menuItem = new JMenuItem("Preset Field 3");
                menuItem.addActionListener(handler);
                menu.add(menuItem);
                return menuBar;
            }// end createMenuBar method
        }//end class MCalMenu
        // class for menu events
        public class MenuHandler extends JDialog implements ActionListener
            public void actionPerformed(ActionEvent e)
                if ( e.getActionCommand() == "Preset Field 1")
                    termField.setText("1");
                }//end if
                else if (e.getActionCommand() == "Preset Field 2")
                    termField.setText("2");
                }//end else if
                else if (e.getActionCommand() == "Preset Field 3")
                   termField.setText("3");
                }//end else if   
            }// end actionPerformed method
        }// end MenuHandler class
        public void createAndShowGUI()
            JFrame frame = new JFrame("MenuItem TextField Update Fail");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            MenuItemTest myMenuItemTest = new MenuItemTest();
            MCalMenu myMCalMenu = new MCalMenu();
            frame.setJMenuBar(myMCalMenu.createMenuBar());
            frame.setContentPane(myMenuItemTest.createContentPane());
            frame.setSize(200, 200);
            frame.setVisible(true);
        public static void main(  String args [] )
            MenuItemTest myMenuItemTest = new MenuItemTest();
         myMenuItemTest.createAndShowGUI();
    }

    I think that your problem is that your createAndShowGUI method is creating two separate and distinct objects when you run this program: a MenuItemTest object and a MCalMenu object. As distinct objects, they don't share instance variables which means that this program has two termField JTextFields, one which is visible and the other which is not visible and which you are trying to change. This won't work.
    The other problem is here:
    if ( e.getActionCommand() == "Preset Field 1")don't compare strings with ==. Better to use the String method equals(...)

  • How to prevent iTunes for Windows from "Updating iTunes Library"? (Library is on a NAS and managed by iTunes for Mac. Now getting update wars between Mac and Windows versions of the player.

    How to prevent iTunes for Windows from "Updating iTunes Library"?
    My library is on a NAS and managed by iTunes on a Mac. I can connect from wife's Windows laptop using iTunes for Windows but every time I do, it Updates iTunes Library. Next time I log in from my Mac it Updates iTunes Library in return. It appears I'm experiencing "Update Wars" between the Mac and Windows versions of iTunes. I would like to allow my wife to stream iTunes songs to her new laptop but I don't want any updates from this source... prefer to manage the library from my Mac and not allow Windows to do any thing other than listen to existing playlists.
    Thanks for any help/suggestions.

    Connect the PC to the library on the NAS. Wait while "updated".
    Under Edit > Preferences > Advanced make sure the media folder is correctly pointed at the media folder on the NAS. If not correct, close iTunes, wait a few moments, then open iTunes again.
    Close iTunes on the PC. Do not open iTunes on the Mac.
    Copy the library files, iTunes Library.itl, iTunes Library Extras.itdb, iTunes Library Genius.itdb, sentinel and the folder Album Artwork into an empty iTunes folder on the PC, for example C:\iTunes.
    Click the icon to start iTunes and immediately press and hold down SHIFT. Keep holding until prompted to choose or create a library. Click choose and browse to the copied .itl file, e.g. C:\iTunes\iTunes Library.itl
    The library should now work properly on the PC, however check the setting for the media folder. If needs be correct, close iTunes and reopen.
    Open iTunes on the Mac. It will update again, but that should be last time.
    tt2

  • Change description of update rule between ODS'es

    Hi!
    In a BW 3.5 system I have the following problem: I cannot change the description of an update rule between two ODS'es.
    When creating such a rule the system automatically generates the technical name and takes the description of the source ODS for the naming of the update rule. Afterwards I have changed the description of the ODS. I have deleted the old update rule and recreated it. When selecting the source ODS from the F4 picklist the new description can be seen. When the source ODS is selected and the update rule is generated, the old description has appeared again however.
    Does anybody knows how this is possible and what can be done about it?
    Best regards,
    Hans

    have you tried regenerating an export DataSource out of the ODS?

  • Microsoft Intune Service update planned between July 22 and July 30

    Microsoft Intune Service update planned between July 22 and July 30
    We will be releasing the next service update for Microsoft Intune between July 22 and July 30. This Intune service update will deliver behind-the-scenes enhancements, allowing us to continue providing you with a high quality product experience. New product features will not be included as part of this service update.
    To see the specific timeframe for when your tenant will be updated, please visit the Microsoft Intune status page. You can identify the Service Instance that your Intune subscription is running on by opening your Intune administration console, clicking on the Admin tab and then selecting View Service Status. Your Service Instance will be displayed at the top of this page.
    Additional resources:Visit the what’s new in Intune page on TechNetSubmit feedback and...
    This topic first appeared in the Spiceworks Community

    Good morning ranatlas,
    We were able to resolve the issues you had with your service. We did do some extensive troubleshooting to isolate the slow speed issue. Please let us know if you have any more questions or concerns here on the forums. You were a pleasure to work with and our team wishes you a great day.
    Thanks again,
    Rachel_VZ

  • Creating update rules between 2 Infosources

    Can anyone mention the steps for creating update rules between two 3.0 Infosources.
    Thanks,
    Shweta

    Hi,
    Have a look at these documents:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50a29380-7adc-2e10-cfa2-fa55bcb17710?QuickLink=index&overridelayout=true
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/37dda990-0201-0010-198f-9fdfefc02412?QuickLink=index&overridelayout=true
    Regards,
    Sunny

  • How to sever the update connection between my 2 iPhones?

    I have an iPhone 4 and and 2 iPhone 5's that I use together.  they have an auto update function that when I add a contact or note in one phone, it automatically updates the other 2 phones.  I want to know how to sever the update function between phones.  anyone know how to do?

    I suspect the reason your devices are still syncing contacts is that they are syncing them with another service such as Google, Yahoo or and exchange account rather than iCloud.  Go to Settings>Mail,Contacts,Calendars and tap each of your accounts to see if you have contacts syncing turned on.  If you do, you'll have to turn that off in order to stop syncing them across your devices.
    If only some of your notes are syncing across your devices, it's probably because not all of them belong to the iCloud account (iCloud only syncs contacts that belong to the iCloud account).  If you want them all to sync with iCloud, you'll have to open the Notes app, tap Accounts, then open the notes in your non-iCloud accounts and copy and paste the text into new notes created in the iCloud account.
    To have your photos sync between your phones, go to Settings>iCloud>Photos and make sure My Photo Stream is turned on.  After that, new photos added to the camera roll will be added to your photo stream whenever the Camera app is closed, your photo is connected to wifi, and has at least 20% battery life remaining.  You can access these photos in the My Photo Stream album within the Photos app.
    To determine if you're backing up to iCloud, go to Settings>iCloud>Storage & Backup to see if iCloud Backup is turned on.
    If you delete your iCloud account from your phone and want to keep your date, begin by saving any photo stream photos to your camera roll and emailing any notes that you are syncing with iCloud to yourself.  Then go to Settings>iCloud, tap Delete Account, provide your password and choose Keep on My iPhone when prompted.
    If you create a new account on one of your phones you can sync the data in the new account with your other phones in the future by simply signing into the same account on your other phones in Settings>iCloud.  When you do, the iCloud data in the new account will download to them as well.

  • Hey guys, Just want to know if i can jump from osx 10.5.8 straight to 10.6.4? Is there an update in between ? All i see available to purchase from apple is osx 10.6 (there is no third number)

    Hey guys, Just want to know if i can jump from osx 10.5.8 straight to 10.6.4? Is there an update in between ? All i see available to purchase from apple is osx 10.6 (there is no third number) but yet i saw a guy online selling snow leopard 10.6.3 so it left me wondering if i would need to purchase two upgrades as oppose to one!
    Cheers

    Updates from 10.x.0 to 10.x.last are traditionally free, and are available via Software Update.
    The version upgrades from 10.x to 10.y will traditionally cost you some money.
    Make sure your Mac meets the requirements for 10.6 — if you're on PPC, you cannot upgrade to 10.6.  (For reference, here are the Lion 10.7 system requirements.  The 10.7 upgrade requires 10.6.6 or later, and can be purchased by calling Apple directly and acquiring a download code, if it doesn't show up in the Mac App Store for you automatically.  I don't think your hardware would be supported with 10.8, if you're presently running 10.5.)
    In any case, you can purchase an official Apple Snow Leopard 10.6 DVD disk for US$20.
    Back up your system before installing the new software.
    Once you install 10.6, you'll run software update and the 10.6.8 combo update will be downloaded and installed for you.  That's free.  10.6.8 allows you to use your trackpad, as well as access the Mac App Store and some other tools; it's the most recent version of 10.6.

  • Updating textfield with DEL key not taking into account

    I have a decimal field which accepts only numerals...
    after modifying the value in the field and pressing an OK button...the new value is reflected in a table...
    but if i modify the same field value using the "delete" key and press OK...the new value is not taken into account....
    but the same works with "backspace" key...
    So do i need to set anything to respond to del key...
    Thanks

    Also i am not able to put the code here as it is a huge applicationI did not ask for your entire application. I asked for
    demo code means code that we can compile and execute, but it only contains the code relevant to your problem
    Here is an example:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DemoCode extends JFrame
         JTextField textField;
         public DemoCode()
              textField = new JTextField();
              getContentPane().add(textField, BorderLayout.NORTH);
              JButton button = new JButton("Update Database");
              button.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        System.out.println(textField.getText());
                        textField.setText("");
                        textField.requestFocusInWindow();
              getContentPane().add(button, BorderLayout.SOUTH);
         public static void main(String[] args)
              JFrame frame = new DemoCode();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }If you can't create a simple demo then you don't understand your problem and if you don't understand your problem then how are we supposed to?
    custom field So you probably have a coding problem and we have no idea what your code looks like
    that accepts only decimal values and why are you not using JFormattedTextField?
    And this problem is not seen if i modify the custom field using any other key say like "Backspace".Again this problem doesn't make sense since the character should be removed from the text field before the OK button is pressed.

  • How to update something on different JFrame...?

    Hi!
    How can you update a component on a JFrame different from the one where the action is performed?
    I ve tried passing a reference of that frame and invalidating anything possible... but did not work! I desperatly need help! Do you have any example?
    Br
    oxinoschar

    Do you have any example?much better for you to post the code you are working with

  • Data comparison and update/insert between two schemas in same database

    Hi all,
    I have requirement like this. In one database, i am having two users, user1 and user2. Both users is having same tables and structure wise also same. In user1, data will be populated by job.
    Now, what i want to do is, i have to find out difference between user1 and user2 data and the Difference data will be updated/inserted into the user2.
    Any ideas please...
    Thanks in advance,
    Pal

    Will trigger help you ... ie. for every update/insert on user1 will do on user2-- it is heavy to do for all table...
    --svmg                                                                                                                                                                                                                                                                   

  • Pages not updating iCloud between iPad and IPhone

    Can somebody please help?
    My Pages app won't stream the current documents to my iPhone using iCloud .
    I've tried everything I could possibly do. I've deleted the Pages app off my iPhone and started again. It just won't update the current documents that reflect on my iPad.
    It just has the arrows pointing upwards on the top right hand corner of quite a few documents. This is suggesting that there is no Internet connection when there is. I've tried it over WiFi and on 2 separate Bluetooth pairings with 2 iPhones. Each time it is connected with the Internet but the arrows still suggest otherwise.
    I have turned every possible iCloud on in every area. Turned them off then on, reset my phone from scratch doing a clean install not using a previous back up. Still didn't work...  Then going back and resetting using a previous back up... Still didn't work :(
    I have a 6 month old Mac Mini, the latest iPhone  5 and one month old iPad 4 with the current software updates.....
    Please help
    Regards Gareth

    I believe you are misunderstanding.  You don't sync apps between iPad and iPhone, and iCloud has nothing to do with any of this.  There is a setting in Settings -> Store where you can set each device to automatically download NEW apps, meaning that when you buy a new app on one device, the other automatically downloads it.  However, this is for new downloads only.
    For your existing apps, you can simply connect each device to your computer and move the desired apps to it in iTunes.  Or you can go to the App Store and re-download those apps.

  • Optimize update inforamtion between WLC and WCS

    Hi,
    I have a WCS in 4.1.83 and 3 WLC 4404-2 12AP in 4.1.171.0 (ans ER).
    I'm think that the update of information between WLC to WCS are too slow. The update is about inforamtion, like client associated, ....
    Do you know if it's possible to change the update pooling of the WCS ?
    Thx

    Under WCS, Administration, Background Tasks,
    you can change the data collection settings

  • Executing Methodes between different JFrames

    hi everybody.
    I have a prop and dont know what the best way is to fix it. There are two JFrames (named F1 and F2) wich are created by a main class (lets say F3). Does anybody know what the best way is to get the reference between those two objects (f1 and f2) so that i can call methodes between those objects (f1,f2). For example i want to perform a methode of f2 from the first JFrame f1 without using a static context.
    in f1 something like this:
    f2.bar();
    thx

    Kangal,
    I suspect Kangal is another alias for CoWork? Spelling and syntax are very similar to posts under that ID. If not, please see this thread:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=388361&tstart=0&trange=100
    --A                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Whats the difference between a JFrame and a jsp?

    I recently came across "JFrame" from an online tutorial, the create .java. I thought jsp's were used for building web interfaces not .java. Can I use JFrames to design forms for a web site?
    Okay, I'm new to this so humor me.
    Thaks-

    JFrames are typically used with applications.
    From the API:
    An extended version of java.awt.Frame that adds support for the JFC/Swing component architecture. You can find task-oriented documentation about using JFrame in The Java Tutorial, in the section How to Make Frames.
    A JSP page is a web page interperted by a http server and sent to a client browser.
    JJ

Maybe you are looking for

  • Is there a way to delete multiple pictures at the same time from the iphone4s?

    Is there a way to deleter multiple pictures at the same time, from my iphone4s? I know how to delete one at a time. Thanks

  • SAP BI Mobile Publishing Webi report issue

    Hi All, We want to use the BI Mobile App on IPad for Webi reports. The app is successfully implemented on the IPad, connection to BO server is done, categories are visible. But no report. In Webi I tried to publish my report to the respective 'mobile

  • Linux Sh script is not running in forms10g(10.1.2)

    Hi The Oracle Forms server is installed in Linux. I have placed the below host commands in forms10g. The Host command is running but shell sh script is not executed. BEGIN :GLOBAL.DIR_PATH:='/forms/shell_files/'; Host(:GLOBAL.DIR_PATH||'my_shell.sh'|

  • "Internet Mail - Problem during delivery processing" email received

    Every email I'm receiving as of this morning is accompanied by an email from [email protected], entitled "Internet Mail - Problem during delivery processing" Is this an issue on the Mac server side or a problem with my Mail app? Many thanks in advanc

  • Destroying a message producer

    We have a Sun MQ JMS provider which provides us destinations. The process is something like this: 1. There is a queue, where a message is posted. 2. I have a java consumer, which listens on this queue. (via JNDI lookup). 3. I do some processes and ba