• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

close window

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 99
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm placing my code below
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic