Results 1 to 6 of 6
  1. #1
    SBL
    SBL is offline Member
    Join Date
    Nov 2009
    Posts
    9
    Rep Power
    0

    Default Closing a JFrame

    Hi there,
    Ive created a program thats essentially a address book GUI. In this i have a function that allows u to add a contact. When this is clicked it creates a new JFrame my question is what code can i use to create a JButton that will just exit that JFrame and not close the program.
    cheers
    simon

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Don't create and show another JFrame. Instead create and show a JDialog, and then you can simply call dispose on the dialog when you're done with it.

  3. #3
    SBL
    SBL is offline Member
    Join Date
    Nov 2009
    Posts
    9
    Rep Power
    0

    Default

    Ive already created another JFrame...

  4. #4
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    Ive already created another JFrame...
    Well, now is a good time to learn normal programming conventions. An application typically has a single JFrame and multiple helper JDialogs that popup for additional information/functionality. To change your code all you need to do is change "Frame" to "Dialog".

  5. #5
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    Now is also a good time to start taking or ignoring advice instead of arguing about it.

  6. #6
    sky
    sky is offline Member
    Join Date
    Nov 2009
    Posts
    96
    Rep Power
    0

    Default

    In the Java Swing tutorial are explained all those things. Just take a look at it.

Similar Threads

  1. Closing Popup JFrame in Applet
    By Arsenic in forum Java Applets
    Replies: 3
    Last Post: 04-10-2009, 09:37 PM
  2. Replies: 5
    Last Post: 06-26-2008, 04:16 AM
  3. JFrame (closing under a condition)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-12-2008, 12:17 PM
  4. Closing packages
    By uncopywritable in forum New To Java
    Replies: 0
    Last Post: 08-14-2007, 12:47 AM

Posting Permissions

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