Results 1 to 5 of 5
  1. #1
    blackz is offline Member
    Join Date
    Sep 2011
    Posts
    10
    Rep Power
    0

    Default Netbeans GUI EXIT button?

    I want to implement Exit command for a window which open thru another window by NEW button.

    The setups should be like this:

    Window1(click NEW button) -> Window2(click NEW button) ->Window3(click EXIT button) ->Window2



    btw, I am using this:

    private void jButton1ActionPerformed(java.awt.event.A evt) {
    System.exit(0);
    }

    When I click EXIT in Window3, it closes all the 3 Windows


    Thanks

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Netbeans GUI EXIT button?

    Java Code:
    System.exit(0);
    That's what the exit() command does: it's for shutting down the whole Java virtual machine. The API docs comment ominously "This method never returns normally".

    If you want to close the window containing the exit button, just do that. setVisible() can be used to "close" windows.

    You don't say what sort of component is involved (JFrame, JDialog etc) but the How to Make Frames page in Oracle's Tutorial will be useful. It contains a section on how to close them (including how to respond to a user closing a frame).

    [Edit] I've just realised this is in the SWT/JFace forum... The point that you shouldn't use exit() remains, but you should look at the API docs of the component you use to represent a window to find a method that allows it to be hidden or deleted entirely.
    Last edited by pbrockway2; 04-01-2012 at 09:45 PM.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Netbeans GUI EXIT button?

    Quote Originally Posted by pbrockway2 View Post
    [Edit] I've just realised this is in the SWT/JFace forum...
    ... which isn't where it should be. The posted code
    Java Code:
    private void jButton1ActionPerformed(java.awt.event.A… evt) {
    shows clearly that this is a Swing/Netbeans question, and that the code has been generated by the visual designer; also that it has been corrupted in the course of copy/pasting.

    I'm moving the thread to AWT/Swing. To blackz, I suggest you dump the visual designer. It's an advanced tool, only worth learning if you plan to make a career of GUI design. Learn to hand-code your GUIs, with guidance from the tutorial and the API.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Netbeans GUI EXIT button?

    Cross posted
    Netbeans GUI EXIT button? - Yahoo! Answers

    Any more?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    blackz is offline Member
    Join Date
    Sep 2011
    Posts
    10
    Rep Power
    0

    Default Re: Netbeans GUI EXIT button?

    Thanks everyone. Problem solved.

Similar Threads

  1. Replies: 9
    Last Post: 03-07-2012, 05:27 PM
  2. problem with the button "exit"
    By mike28 in forum Java Applets
    Replies: 3
    Last Post: 11-19-2011, 03:42 AM
  3. Replies: 0
    Last Post: 04-28-2010, 01:39 PM
  4. Button Group in Netbeans.
    By makpandian in forum NetBeans
    Replies: 2
    Last Post: 03-22-2010, 01:26 PM
  5. Adding EXIT button on MIDlet form
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-22-2007, 10:13 AM

Tags for this Thread

Posting Permissions

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