Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to close a frame by clicking Esc Button?

 
Sathiq Ali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have one problem in Java Swings. I have a one main window which is a frame and that contains three buttons, If I clicked one Button, It has to open a new Jframe window. The other Two buttons are such as Save and Cancel. The new Window also contains two buttons such as Save and Cancel .Now if I click the Esc button from the key Board, It has to close only the new window. But Now It is closing both the windows. how to make difference b/w two windows while clicking ESc button?
Advance thanks

[ January 31, 2006: Message edited by: Sathiq Ali ]
[ January 31, 2006: Message edited by: Sathiq Ali ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally you'd add KeyListener to the second frame, which listens for the escape key, and closes the window when it's pressed. What does the code do in response to an escape key - post the relevant excerpt of your listener routine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic