Updating a variable from a new window

I have a frame which displays various labels and lists. I want to open a new frame, put in some input, then update the original frame. So far I have done this my making the original variable "static" and modifying it from the new frame but this is a pain. Is there an easier way?

Can I do that if I am instantiating the second frame
from the first? How do I pass myself to the new
frame's constructor?
// called from inside FirstFrame
SecondFrame secondFrame = new SecondFrame(this);

Similar Messages

  • Problem with gettin text from a new window

    Hi
    I have been trying to for sometime to work out why i cant get this to work...I open a main window which opens a new window when a button is pressed. This window has a text field where data can be typed, it has a button called "Send" which then allows the data to be send. However, when "Send" is pressed, a NullPointerException is throwen in the ActionListener because it is unable to get the text from the text field.
    Anyone got any idea why, have done a small mock up just to give an example :
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    public class TwoWindows implements ActionListener{
         private JTextField chatLine;
         public volatile boolean start = false;
         //******************************GUI Production******************************
         public TwoWindows() {
              JFrame frame = new JFrame("Multicast Discovery");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel connectpanel = new JPanel();
              JButton button3 = new JButton("Open New Window");
              button3.setActionCommand("connect");
              button3.addActionListener(this);
              connectpanel.add(button3);
              frame.getContentPane().add(connectpanel, BorderLayout.PAGE_END);
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         //*****************************action listener******************************
         public void actionPerformed(ActionEvent ae)
              //get what button was pressed
              String button = ae.getActionCommand();
              if (button.equals("search"))
                   System.out.println("\n Do Something!");     
              else if (button.equals("cancel"))
                   System.out.println("\n Do Something else!");     
              //start new window here
              else if (button.equals("connect"))
                   setupChat();
              if (button.equals("send"))
                    if (start)
                              //try to get the data from the new window
                              String s = chatLine.getText();
                              System.out.println("This has been inputted : " + s);
         //*****************************setup new window*****************************
         public void setupChat()
              JFrame frame01 = new JFrame("TCP Chat Window");
              frame01.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // Set up the chat pane
                 JPanel chatPane = new JPanel(new BorderLayout());
                JTextArea chatText = new JTextArea(10, 20);
            chatText.setLineWrap(true);
            chatText.setEditable(false);
            chatText.setForeground(Color.blue);
            JScrollPane chatTextPane = new JScrollPane(chatText,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            JTextField chatLine = new JTextField("Type Here!");
            JButton button4 = new JButton("Send");
              button4.setActionCommand("send");
              button4.addActionListener(this);
              chatPane.add(chatLine, BorderLayout.CENTER);
              chatPane.add(button4, BorderLayout.SOUTH);
             chatPane.add(chatTextPane, BorderLayout.NORTH);
              chatPane.setPreferredSize(new Dimension(200, 215));
              frame01.getContentPane().add(chatPane);
              frame01.pack();
              frame01.setLocationRelativeTo(null);
              frame01.setVisible(true);          
              start = true;
         public static void main(String[] args)
         new TwoWindows();
    }

    public class TwoWindows implements ActionListener{
         private JTextField chatLine;
         public volatile boolean start = false;
         public void setupChat()
    JTextField chatLine = new JTextField("Type
    ld("Type Here!");
    You have two variables called chatLine. One is a class field the other is a local object in setupChat.
    Change
    JTextField chatLine = new ...
    to
    chatLine = new ...

  • I can't get home sharing to turn on on my computers. I have a PC running windows XP that has a large library on it that I want to access from a newer windows 7 PC. I have turned home sharing on in both, same apple ID. I just will not come up. Any ideas?

    I can't get home sharing to turn on on my computers. I have a PC running windows XP that has a large library on it that I want to access from a newer windows 7 PC. I have turned home sharing on in both, same apple ID. I just will not come up. Any ideas?

    Ugh, disregard.. it magically started working -_-

  • HP C6180 (wireless) gives "Ink System Failure" when trying to print from my new Windows laptop

    HP C6180 (wireless) gives "Ink System Failure" when trying to print from my new Windows laptop

    Hi @Maxuss,
    Thank you for visiting the HP Support Forums! I see you are getting an 'Ink System Failure' on your HP Photosmart C6180, so you are unable to print. 
    Please complete the steps listed here: An 'Ink System' Error Code Displays on the Front Panel
    If after the reset you are still getting the error message, please call our technical support at 800-474-6836. If you live outside the US/Canada Region, please click the link below to get the support number for your region.
    http://www8.hp.com/us/en/contact-hp/ww-phone-assis​t.html
    I hope this helps!
    HevnLgh
    I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to the left of the reply button to say “Thanks” for helping!

  • Request coming from the new window............... ?

    Hi All,
    Anybody please tell me how to check the request is coming from the new window.
    like if I copy the following url
    http://forum.java.sun.com/post!default.jspa?forumID=33
    and open it in a new window then I have to check that this url is coming from the new window not from the link.
    please reply soon.
    Thanks

    You would have to make the link use javascript to use a Form with a method of POST to add a parameter to the request and submit the form.
    You would have to use POST to hide the fact that you are using a parameter, otherwise the user could just copy the address with the parameter into a new window.
    So this would work in two ways:
    1) You could have a request.getParameter. If it is NULL then the user copy and pasted the link. If it is non-null then the link was clicked on.
    2) This will also force the clicked link to go to your servlet's doPost method and direct navigation to go to the servlet's doGet method.

  • Can't use OfficeJet L7780 scanner from my new Windows 8.1 laptop

    I purchased a new Microsoft Surface Pro 3 laptop with Windows 8.1 and used Windows to install a driver for the OfficeJet Pro L7780 All-in-One.  The printer works with the new driver, but I have no software that lets me control the scanner from my new laptop.  Previously on my desktop with Vista where the All-in-One printer was first installed using a wired home LAN, I had the HP Solution Center software that allowed me to control the scanner from my computer.  I tried to use the Windows Fax and Scan software that is on the new laptop, but it says "No scanner was detected". 
    Note:  I do have the install disks for the All-inOne, but was afraid that they would not work for Windows 8.  Any help will be greatly appreciated!
    UPDATE:  I found out about the HP Print & Scan Doctor and ran it.  It fixed my problem by installing the HP Solution Center.

    Hello danchu8899,
    I understand that you are having an issue with getting the printers software installed. First step that I would suggest is to clear the temp folder. I have included the instructions below, for you to follow.
    1) Press the Windows Key and the letter R
    2) In the open field type %temp%
    3) Click ok
    4) Delete all items listed in this folder
    NOTE: if you are not able to delete the item please skip it.
    Next click on the following link 'HP Photosmart and Officejet Full Feature Software and Drivers'. Click on the orange download button. When the option appears to run or save. Please select the option to save the download.
    After the download has finished, please right click on the software and run as administrator. Then follow the on screen instruction for installing the printer.
    Thank you.
    I worked on behalf of HP

  • Windows Update in Endless Loop of 'Installing updates" and "Undoing changes" on New Windows 8.1 Pro Install

    I am setting new Windows 8.1 Pro computers, and am installing Windows 8.1 Pro to bare drives.  Everything goes fine until Windows Update starts installing updates, and then the computer goes for hours installing updates, and then "We
    could not complete the updates Undoing changes".   It's an endless loop. It seems to be the same 38 updates.  This is a recent phenomenon.  I have not run into this until the last week or two on several new computer installs.
    Again these are brand new installs, so something is clearly wrong with the Windows updates.
    If anyone can please tell me how to avoid this, it would be much appreciated.
    Michael

    Hi Michael,
    "  This is a recent phenomenon"
    Have you made any modifications to the machines ?
    To resolve this issue ,running the built-in troubleshoot tool is a very good beginning .It will automatically diagnostic the windows update components and check the configurations for us .
     Control Panel\All Control Panel Items\Troubleshooting\Fix problems with Windows Update
    If there are antivirus software installed in these machines, please turn off them temporarily to have a check.
    The command line included in the link as S.Sengupta posted is very useful and convenient to repair the windows corrupted files .We can have a try .
    "sfc /scannow" ,"DISM.EXE /online /cleanup-image /restorehealth "
    We also can check the windowsupdate.log for more information to troubleshoot this issue .
     Run "windowsupdate.log"
    If you have trouble in analyzing the log ,please upload them to the OneDrive and paste the link here .
    Best regards

  • How can I stop Safari from opening new windows unless I want them?

    Since Safari 5.02, there is no box to check in the General Preferences to stop Safari from opening a new window when I click on a link. My expectation is to only go to a new window when I want to do it. Most of my searches go down a rabbit hole and I just want to go backwards without closing page after new open page (Same problem with Tabs. I don't want new Tabs all the time either. In fact, the only time I really care about multiple open Tabs or Windows is when I need more than one Window open for data comparison or something like that...)
    This is an incredibly annoying new behavior of Safari that I want to shut off. I have 20 windows open in the Window list right now. (I regularly shut off Safari to clear up all the useless abandoned windows.) Firefox doesn't do this, but I prefer Safari.
    I tried to search this one, but maybe am not framing the question properly. See lots of discussion of forcing new tabs, but that is not what I am looking for....Can anyone help me?

    Thanks Baltwo,
    I will try it, but I don't want new pages in tabs either. I simply don't want the link to open in a new page or tab unless I ask for one. My initial trial has google links opening in new tabs. Why can't I just go down the paths on the same page like the old days? Especially after I find what I want, I will go somewhere else.
    With your recommendation, I think that instead of pages open, I will have an abundance of tabs?
    Guess I am getting inflexible in my old age. If this is the only option, it is an "improvement" that I don't like yet.
    Firefox doesn't do it.

  • How stop FF31 from opening new window? I want to open all links in new tab at top of page.

    I think the following, quote below, from the help page is my problem.
    I have this one website I use that when I click on a link within the website it is opening a new window with the tab at the bottom. Also, when this happens, I am losing the orange FireFox rectangle, bookmarks and navigation options. How can I set FF31 so that the link opens in a new tab and I keep all my options? I am using Classic Theme Restorer 1.2.3. I also notice that in the new window I lose the ability to use some of the addons.
    I have two laptops and both are running FF31 and W7. One of them is working perfectly and the other is having this problem. As far as I can tell they are both set up the same. The only difference is that when I upgraded to FF31 they both had difference older versions of FireFox. I also read in the help forum that maybe I need to go back to FireFox 28 to accomplish what I am trying to accomplish.
    I noticed that when I go under about:config that the version of FF that is not working has fewer available options versus the version that is working. An example would be that the working version has "browser.tabs.onTop" where on the other laptop this is missing.
    >>>Open new windows in a new tab instead: This option controls whether links from other applications or from web pages which request to open them in new windows are opened in a new window or a new tab in the most recent window.
    Note: If you have chosen to open pages in new tabs, Firefox will ignore this option and will open a new window from a link if the page author specified that the new window should have a specific size, because some pages can only be displayed correctly at a specific size.<<<
    Thank you in advance for any help,
    yeto

    You can override how links are opened via the browser.link.open_newwindow.override pref.
    *http://kb.mozillazine.org/browser.link.open_newwindow
    *1: current tab; 2:new window; 3:new tab;
    Use this for links opened via JavaScript.
    *http://kb.mozillazine.org/browser.link.open_newwindow.restriction
    See also:
    *http://kb.mozillazine.org/Prevent_websites_from_disabling_new_window_features

  • How to restore iPhone backup from a new Windows laptop?

    I am using iPhone 4S and my phone went to recovery mode while updating iOS 8.1
    Phone got started after a while and I am having backup of the phone in iTunes as well but unfortunately, I am not able to restore the backup!
    I have copied the backup from %appdata% -> Roaming to my external hard disk!
    So, is there any way to restore it from a new laptop while using my external hard disk?
    I would appreciate if someone will let me know the necessary steps!

    dna4 wrote:
    i dont have a backup copy from my old computer
    Really?  Why would you do that?
    You can transfer itunes purchases from your iphone to your comptuer.  Without syncing:  File>Transfer Purchases
    You should import any pics taken with iphoen to the new computer, as you would with any other digital camera.
    You can e-mail the pics that you synced to the iphone to yourself.  They will not be of the original quality.
    If you enter one unique contact and calendar entry on the new comptuer, then when you sync, you should get the option ot merge the data.
    No backup is not good.

  • When opening a new window, any clicks within the new window click through to the original window so you can't scroll or save from the new window.

    Anytime that a new window is opened (such as when sending an email message or opening a pdf) I am unable to click on the new window. I can't click send or click on the scroll bars of the new window. If I attempt to click on the window it clicks on whatever is behind the window instead. If the new window opens with a cursor within it then I am able to type or scroll through with keyboard arrows, but cannot click or use the mouse scroll buttons. I also cannot choose items from drop down menus with the mouse (even in the original window). I must use the keyboard arrows to select any menu options.

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to stop Finder from opening new windows to view contents of folders.

    I have 2 folders on my desktop, called "Home" and "Work." Both are aliases to files stored in user/documents on my HD. Both contain many folders within folders within folders and, ultimately, documents. When I double click on the "Home" desktop alias, a finder window opens showing contents. When I click on any folder within that window, it does what I want it to...switches to the contents of that folder (within same window, without opening a new one.) This works for everything in that folder.
    When I double click on a folder within the "Work" folder, however, it opens a new window at every level. By the time I get to the document I want, I may have 5 or 6 windows open, which I then have to manually close.
    I have gone into Finder/Preferences/General and the "Always open new window" box is NOT checked. Any one know why it would still be doing this? (No new applications are opening when I click on the folders, just a new finder window.) And why would it do it for one desktop folder and not the other?
    I looked through discussions till my head spun and only saw the Finder/Preferences fix, so I'm hoping there's another fix, like a preference file somewhere that I just need to trash. Any help would be appreciated.
    Powerbook G4   Mac OS X (10.3.9)  

    I don't know if this is the problem, but for windows in "Icon" or "List" view that are set so that the "Toolbar" is not showing, a folder opened within that window will tend to open a new window. This is just a difference in behaviour between the two modes. To show / hide the toolbar, try clicking the elongated button in the upper right corner, in the "titlebar" of the window, or choose "Show Toolbar" / "Hide Toolbar" from the "View" menu.
    Additionally, a workaround might be to switch to "Column" view ("View" > "as Columns" ⌘3), since opening a folder within a window in "Column" view does not appear to spawn a new window, even with the "Toolbar" hidden. Another option might be to hold down the "option" key while opening the folder - this causes the previous window to close as the new window is opened.

  • New Window from "FILE- NEW-WINDOW" duplicates all the currently open tabs in the new window. I want new window with just the "Home" tab please?

    Running Firefox 3.6.13 on 64Bit Win7.
    I like to group tabs on a topic in a window, and when the tabs get to be too many, or a new topic, I do FILE->NEW-WINDOW and expect a new window with just one default (Home) tab. Instead I get a new window with ALL the tabs of the first window.
    I have checked all the Options I could find. Nothing helped. I CAN make a new Window with just one tab if I right-click a link and say "Open in NEW Window".

    A new window should only open with the home page(s).<br />
    If you see differently then you need to check your extensions.
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]

  • Updated my computer from vista to windows 7. all my itunes library has disappeared?

    My computer crashed and was changed from vista to windows 7. since then my itunes library has disappeared. How do I get it back.

    Photoshop Elements 10 Direct Download Links: Free Trials, Premiere | ProDesignTools
    This may help. Folks who have used this report that it is critical to follow the instructions precisely.

  • Viewing passed variables in an alert from the new window

    If I am passing a param, SD and ED to another window, how can I view it using an alert when an applet is created.  I have the FirstUpdateEvent established and I place the alert in the function.
    How should the alert look?
    I have tried
    alert([Param.1]); and alert({Param.1});
    alert([SD]);and alert();
    None of these work.  I get errors for each of them.

    You have at least two options for this.  As Sascha mentioned in another post, you can use a JS library to parse the URL string and find the Params that way.
    Or you can put an applet on the page that has <param name="param.1" value="{Param.1}"> and then use JS to reference the applet param.
    But, there isn't a way, that I know of to put an URL param directly in JS.

Maybe you are looking for

  • JScrollPane Must Scroll to the END ........

    My problem is : I have a JTextArea , and the text inside doesn't fit in it. When this happens , the two ScrollBar should scroll to the END of the text.... Like if a have a JTextArea with 10 rows with a JScrollPane, and my text is 20 rows long, then i

  • Call transaction Failing

    Hi, I have a stranege problem in my hands, i have recorded a bdc for a transaction. I further use it in the call transaction, the problem is if run the transaction in Foreground mode it works fine howver in online mode it doesn't....please help. Rega

  • ICS file - Line breaks

    Hi, I am sending an email with an ICS file as an attachment. Everything work fine, except that when the user opens the ICS file from their outlook, the text is displayed without a line break.   CALL FUNCTION 'SO_OBJECT_SEND'     EXPORTING       objec

  • How do you CHANGE the location (away from Drive C) where Firefox stores temporary files?

    I know where Firefox stores temporary files. I want to CHANGE this location away from Drive C to decrease writes to an SSD. Thank you.

  • Double click home button does not bring up Search

    I installed OS 3.0 on my first generation iPod Touch. On the Settings | General | Home, I selected Search. When I double click the home button, I get the "Dock Connector" dialog. Am I missing something?