GUI Window - Exit Button?

Reply

Join Date: Nov 2004
Posts: 2
Reputation: smitdog1 is an unknown quantity at this point 
Solved Threads: 0
smitdog1 smitdog1 is offline Offline
Newbie Poster

GUI Window - Exit Button?

 
0
  #1
Nov 24th, 2004
Is there a cleaner way to close out of a GUI window in Java then just clicing the X in the upper right hand corner? When I do this I get a NullPointerException error.

Is there a way to put an "Exit" button in a GUI window so that the window (program) closes much cleaner?

I'm aware of the system.exit command, but that's not what I'm looking for.

Any suggestions?
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: GUI Window - Exit Button?

 
0
  #2
Nov 24th, 2004
I think System.exit is the quickest way shutdown apps in java. I usually disble the X button of the GUI and provide an exit menu for exiting.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 2
Reputation: smitdog1 is an unknown quantity at this point 
Solved Threads: 0
smitdog1 smitdog1 is offline Offline
Newbie Poster

Re: GUI Window - Exit Button?

 
0
  #3
Nov 24th, 2004
Originally Posted by nanosani
I think System.exit is the quickest way shutdown apps in java. I usually disble the X button of the GUI and provide an exit menu for exiting.
Yes, I know about the System.exit piece, but how do you disable the X button and provide an exit menu for exiting?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: GUI Window - Exit Button?

 
0
  #4
Nov 25th, 2004
if you get an exception on application shutdown there's something wrong with your application and you shouldn't blame the shutdown hook for it.

As to providing a menu, check your Swing tutorials...
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: GUI Window - Exit Button?

 
0
  #5
Nov 25th, 2004
As to specifically see javax.swing.JMenu API to insert menus in your app ... and to disable the X button :

see javax.swing.JFrame --> setDefaultCloseOperation(int )
setDefaultCloseOperation
public void setDefaultCloseOperation(int operation)Sets the operation that will happen by default when the user initiates a "close" on this frame. You must specify one of the following choices:

DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object.
HIDE_ON_CLOSE (defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects.
DISPOSE_ON_CLOSE (defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects.
EXIT_ON_CLOSE (defined in JFrame): Exit the application using the System exit method. Use this only in applications.
The value is set to HIDE_ON_CLOSE by default.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4
Reputation: mr_bemar is an unknown quantity at this point 
Solved Threads: 0
mr_bemar mr_bemar is offline Offline
Newbie Poster

Re: GUI Window - Exit Button?

 
0
  #6
Dec 21st, 2004
Well. Thats a fine way I didn't knew before.

Are there any possibilities to deactive or hide the "minimize" and the "downsize" Button?

Thanks in advance

Greetings from Germany

Ben
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: GUI Window - Exit Button?

 
0
  #7
Dec 22nd, 2004
I'd guess that the JavaDoc for JFrame will tell you...
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4
Reputation: mr_bemar is an unknown quantity at this point 
Solved Threads: 0
mr_bemar mr_bemar is offline Offline
Newbie Poster

Re: GUI Window - Exit Button?

 
0
  #8
Dec 22nd, 2004
Hmmm. I think 99 percent of the questions in this forum will be solved by reading the docs.......

Why are you here then?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: GUI Window - Exit Button?

 
0
  #9
Dec 22nd, 2004
If I can teach one person to learn to find their own answers I'll have helped one person...
If I regurgitate code for everyone who wants some I've helped noone as they'll still not know how to find their own answers and will forever (or more likely until they end up in the unemployment line) come here for more and more.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: GUI Window - Exit Button?

 
0
  #10
Dec 22nd, 2004
I didnt find any method doing your job .... however you can set a listener for minimizing the window ... if the window is minimized, then you should restore it and bring it to front again.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC