• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Closing Java Frame

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Java Frame that closes when I press Ctrl-C. I expected it to paste. Please let me know how a warning message should pop up when I press Ctrl-C instead of closing the window suddenly. Thanks
 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way I can think of right off the bat is to add a key listener to the JFrame (JFrame.addKeyListener()) that listens for Control-C. When control-C is found, it puts up a warning dialog.

Originally posted by mike farad:
I have a Java Frame that closes when I press Ctrl-C. I expected it to paste. Please let me know how a warning message should pop up when I press Ctrl-C instead of closing the window suddenly. Thanks


 
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just curious; what platform are you using, that is imposing this behaviour?
Geoffrey

------------------
Sun Certified Programmer for the Java 2 Platform
 
mike farad
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WE have both Unix and NT. But this problem is noticed on NT
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CNTL-C is used by most OS's to cancel a process. A java application runs as a process on the OS.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a small simple app using Frame and with the focus on the window CTRL-C does not close the app. (NT workstation)
However if the DOS window in which the application was started has focus and CTRL-C is pressed the application does stop.
(and is it Frame or JFrame that is being used?)
is this any help?
 
Scott Cochrane
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Matt Senecal:
The best way I can think of right off the bat is to add a key listener to the JFrame (JFrame.addKeyListener()) that listens for Control-C. When control-C is found, it puts up a warning dialog.


I thought a Frame is really a window and as such would the WindowListener not be more appropriate - I am probably wrong!
sc
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use NT all the time and this does not happen (unless at the DOS prompt).
Scott KeyListener is the right one since it is a KeyEvent not a WindowEvent.
 
mike farad
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m suprised that the window closing on CTRL-C is not noticed in some cases. My application is a JFrame and the window as well as the DOS prompt are closed when CTRL-C is pressed on either of them. I m looking for a message when some tries to close the JFrame. I guess Key Listener might be the right choice. Thanks for your input.
 
mike farad
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, just noticed that it is a Jdesktop pane. Not a JFrame. Sorry about that.
Mike
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still doesn't close with Ctrl-C with JDesktopPane on NT for me. The only way it closes is with the DOS window having focus.
Maybe you could post your code.
[This message has been edited by Paul Stevens (edited October 02, 2001).]
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic