Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

right hand corner of a window?

corner hand right window
0
Posted

right hand corner of a window?

0

[*] Create an event handler class to extend WindowAdapter. Then override WindowAdapter’s windowClosing() to do the actions you want when a window’s “close” action is clicked. Then add that to the listeners for that window. import java.awt.*; import java.awt.event.*; public class MyFrame extends Frame { public MyFrame(String s) {super(s);} public class WL extends WindowAdapter { public void windowClosing(WindowEvent e) {System.exit(0);} } // do your other Frame stuff } Somewhere in your initialization code, put: f1.addWindowListener( f1. new WL() ); This last syntax is not commonly known to many people yet, it’s another wacky artifact of inner classes. Alternatively, combining the inner class and setting the handler in one go, you could do this: MyFrame f1 = new f(“wave”); f1.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // and/or setVisible(false) and/or dispose() System.exit(0); } }); See also the answer to questions 1.0.19, 1.0.30 and 15.7.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.