Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-22-2009, 08:40 PM
SBL SBL is offline
Member
 
Join Date: Nov 2009
Posts: 9
Rep Power: 0
SBL is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-22-2009, 08:41 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,402
Rep Power: 8
Fubarable is on a distinguished road
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.
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-22-2009, 08:46 PM
SBL SBL is offline
Member
 
Join Date: Nov 2009
Posts: 9
Rep Power: 0
SBL is on a distinguished road
Default
Ive already created another JFrame...
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-22-2009, 10:26 PM
Senior Member
 
Join Date: Jul 2009
Posts: 289
Rep Power: 1
camickr is on a distinguished road
Default
Quote:
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".
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-23-2009, 12:24 AM
Senior Member
 
Join Date: Aug 2009
Location: Pittsburgh, PA
Posts: 265
Rep Power: 1
zweibieren is on a distinguished road
Default
Now is also a good time to start taking or ignoring advice instead of arguing about it.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-23-2009, 03:54 PM
sky sky is offline
Member
 
Join Date: Nov 2009
Posts: 91
Rep Power: 0
sky is on a distinguished road
Default
In the Java Swing tutorial are explained all those things. Just take a look at it.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing Popup JFrame in Applet Arsenic Java Applets 3 04-10-2009 09:37 PM
Can i use a resultset more than once without closing it haneeshrawther Database 5 06-26-2008 04:16 AM
JFrame (closing under a condition) Java Tip Java Tips 0 03-12-2008 12:17 PM
Closing packages uncopywritable New To Java 0 08-14-2007 12:47 AM


All times are GMT +2. The time now is 05:03 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org