HELP!! Close a JFrame closes whole app

Discussion in 'Java' started by brightoceanlight@hotmail.com, Sep 29, 2005.

  1. Guest

    I have an application that extends JFrame.

    When a user presses a button, a smaller JFrame is also opened.

    But when the user clicks on the box with an x in the menu bar of the
    smaller JFrame to close the small JFrame, the whole app closes.

    How can I fix this problem, so only the smaller JFrame closes and not
    the whole app??
     
    , Sep 29, 2005
    #1
    1. Advertising

  2. wrote on 29 Sep 2005 01:08:31 -0700:

    > I have an application that extends JFrame.
    >
    > When a user presses a button, a smaller JFrame is also opened.
    >
    > But when the user clicks on the box with an x in the menu bar of the
    > smaller JFrame to close the small JFrame, the whole app closes.
    >
    > How can I fix this problem, so only the smaller JFrame closes and not
    > the whole app??


    Perhaps the default close operation is not set correctly?
    Have a look at setDefaultCloseOperation() in the JFrame API
    docs.

    -- Sebastian
     
    Sebastian Millies, Sep 29, 2005
    #2
    1. Advertising

  3. Roedy Green Guest

    On 29 Sep 2005 01:08:31 -0700, wrote or
    quoted :

    >I have an application that extends JFrame.
    >
    >When a user presses a button, a smaller JFrame is also opened.
    >
    >But when the user clicks on the box with an x in the menu bar of the
    >smaller JFrame to close the small JFrame, the whole app closes.
    >
    >How can I fix this problem, so only the smaller JFrame closes and not
    >the whole app??


    If you won't show us the code we can only guess what you did wrong.
    See the generic advice on how to set up JFrames at
    http://mindprod.com/jgloss/jframe.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 29, 2005
    #3
  4. Guest

    Thanks for the replies!

    I found the error.

    I set :

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    for each frame. That's why it was closing.
     
    , Sep 29, 2005
    #4
  5. Oliver Wong Guest

    <> wrote in message
    news:...
    >I have an application that extends JFrame.
    >
    > When a user presses a button, a smaller JFrame is also opened.
    >
    > But when the user clicks on the box with an x in the menu bar of the
    > smaller JFrame to close the small JFrame, the whole app closes.
    >
    > How can I fix this problem, so only the smaller JFrame closes and not
    > the whole app??


    Don't set the default close operation to be "EXIT_ON_CLOSE".

    - Oliver
     
    Oliver Wong, Sep 29, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. \A_Michigan_User\
    Replies:
    2
    Views:
    942
    \A_Michigan_User\
    Aug 21, 2006
  2. jakester
    Replies:
    3
    Views:
    1,904
    jakester
    Apr 3, 2007
  3. Duane Evenson
    Replies:
    10
    Views:
    761
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    950
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Replies:
    2
    Views:
    442
    markspace
    Aug 27, 2012
Loading...

Share This Page