Is there an event listener way to a JFrame object to detect when a user clicks on a window, maximizes or collapses the buttons?
We use the JFrame object as follows:
JFrame frame = new JFrame("Frame");
You can use WindowStateListener . How to write Window Listeners in a tutorial shows how to create event handlers associated with a window.
Yes, you can do this by implementing WindowListener methods, namely windowIconified (WindowEvent e), with windowDeiconified (WindowEvent e). For more information visit this
JFrame frame = new JFrame(); frame.addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent arg0) { frame__windowStateChanged(arg0); } });
public void frame__windowStateChanged(WindowEvent e){ // minimized if ((e.getNewState() & Frame.ICONIFIED) == Frame.ICONIFIED){ _print("minimized"); } // maximized else if ((e.getNewState() & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH){ _print("maximized"); } }
Source: https://habr.com/ru/post/918713/More articles:is there a seqFileDir option for "clusterdump" in the latest apache mahout library? - amazon-ec2How to implement Redis Multi-Exec using Spring-data-Redis - javaquantmod :: chart_Series () error? - rMathematica - How to compile BitShiftRight (or Left)? - wolfram-mathematicaHow to efficiently collect data from streams in CUDA? - optimizationβChange source controlβ is not on the menu - Team Foundation Server 2010 - visual-studio-2010IoC Initialize a service using hard work in the constructor, but avoiding the temporary Init () method - c #How to maintain static json file in rails? - jsonDisplaying invalid XML syntax with AvalonEdit - c #Cannot Cancel Team Foundation Server 2010 Solution - tfsAll Articles