how to minimize jframe in java

www.lau‮moc.irutt‬
how to minimize jframe in java

To minimize a JFrame window in Java, you can use the setExtendedState method of the JFrame class with the JFrame.ICONIFIED constant.

Here is an example of how you can minimize a JFrame window in Java:

import javax.swing.JFrame;

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame("My Window");
        frame.setSize(400, 300);
        frame.setVisible(true);
        
        frame.setExtendedState(JFrame.ICONIFIED);
    }
}

In this example, a JFrame object is created and made visible using the setVisible method. The setExtendedState method is then used with the JFrame.ICONIFIED constant to minimize the window.

Keep in mind that minimizing a window does not close the window or end the application. To close a window and end the application, you can use the dispose or setVisible method with the false argument.

frame.dispose();
frame.setVisible(false);
Created Time:2017-11-01 20:42:58  Author:lautturi