web analytics

Java: minimize Application window

The following method could be used to minimize application window, if java.awt.Frame or its subclass is used:

public void setState(int state)
state – Frame.ICONIFIED if this frame is in iconic state;
Frame.NORMAL if this frame is in normal state.


// Close window on ESC
// use it in the constructor of the window, extending JFrame
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
rootPane.registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
    } , stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>




This site uses Akismet to reduce spam. Learn how your comment data is processed.


A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.