• Post Reply Bookmark Topic Watch Topic
  • New Topic

close window  RSS feed

 
sujesh Katri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some one please tell me how to close my output window..i wrote Button class program that executed successfully and displayed output window...i'm trying to close that window but that doesn't...please tell me short cut key to close that output window...i placed some methods like dispose() and System.exit(0) but not work..tell me some short cut key please.
 
Mauro Trevigno
Ranch Hand
Posts: 99
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What technology are you using?

I think you are looking the following:
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


Call 'System.exit(0)' to stop the program.

dipose(): destroy the object and the garbage collector pick the object.


Thanks,
-M
 
fred rosenberger
lowercase baba
Bartender
Posts: 12529
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.exit shuts down the current JVM. That has to close your window. Are you sure it is being called?

Can you post your code (using the code tags) that show us how you create the window, as well as how you close it?
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion would fit better in our GUIs forum. Moving.

Avoid System.exit. It can be a bit vicious. If you have several threads running and one has a incomplete task, the JVM will exit leaving the task unfinished and may corrupt your data.
What sort of “output window” do you have? Is it a Dialogue Window?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Closing a JFrame with a defaultCloseOperation of EXIT_ON_CLOSE also calls System.exit(0) (JFrame.java, around line 313).

So any application which might have a thread that needs to run to completion should use DO_NOTHING_ON_CLOSE and handle the exit in a WindowListener, or override processWindowEvent(...).
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about DISPOSE_etc as a closing operation?
 
sujesh Katri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm placing my code below
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post that again with correct indentation. The unformatted code is really difficult to read, with or without code tags.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really have to use AWT? Swing, which is itself in 'maintenance mode' replaced AWT more than a decade ago.

If you're stuck with AWT, read the API for Frame.
If the program doesn't explicitly hide or dispose the window while processing this event, the window close operation is canceled.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!