Results 1 to 4 of 4
  1. #1
    nolsen01 is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default Close a JFrame, but keep the original open.

    I have a JFrame called FinancialGUI. It has a button that, when clicked, creates a new JFrame called EditPayPeriodGUI. When I exit EditPayPeriodGUI, the entire application closes, but I only want the EditPayPeriodGUI to close. I do have setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) which I'm sure I shouldn't have. But what else do I need to put?



    *SOLVED*
    Instead of using JFrame.EXIT_ON_CLOSE, I used JFrame.DISPOSE_ON_CLOSE which gave me the desired result.
    Last edited by nolsen01; 06-13-2011 at 11:23 PM.

  2. #2
    asifzbaig is offline Member
    Join Date
    May 2011
    Posts
    56
    Rep Power
    0

    Default

    For light operation on EditPayPeriodGUI go with a DialogBox rather than frame with parent frame as FinancialGUI....

  3. #3
    nolsen01 is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default

    EditPayPeriodGUI has 2 JLists, 9 JButtons, and 7 JLabels. 7 of the JButtons bring up DialogBoxes of their own. I've never worked with DialogBoxes, so I'm not sure if this is reasonable to put in a DialogBox. Is it?

  4. #4
    asifzbaig is offline Member
    Join Date
    May 2011
    Posts
    56
    Rep Power
    0

    Default

    Its easy to work with it but in few cases and your case is not like that...

    Now working with frame do one thing, Do not dispose or exit your first frame that is FinancialGUI, call your next frame as:

    Java Code:
    // in button action through which want to open EditPayPeriodGUI
    new EditPayPeriodGUI().setVisible(true);
    this.setVisible(false); //use this only if you want to show only one frame at a time
    and

    Java Code:
    // in button action through which want to back to FinacialGUI
    dispose();
    new FinacialGUI().setVisible(true);
    Do one more thing, setDefaultCloseOperation(DO_NOTHING); in EditPayPeriodGUI, and provide a manual button to back to previos frame by code as written above..

    better luck..

Similar Threads

  1. donīt close a jFrame
    By flaquitqm in forum AWT / Swing
    Replies: 4
    Last Post: 04-25-2010, 02:57 AM
  2. Can't close JFrame
    By dunafrothint in forum AWT / Swing
    Replies: 5
    Last Post: 12-16-2009, 05:00 PM
  3. Open and close web browser
    By ali_sakar in forum New To Java
    Replies: 2
    Last Post: 11-03-2009, 12:28 PM
  4. How to close an open JFrame window from a jsp page?
    By kasisaiganesh in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-27-2008, 06:29 PM
  5. How to close a JFrame
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 05:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •