Java Swing How to - import java.awt.Frame;








Question

We would like to know how to import java.awt.Frame;.

Answer

//  ww w. j  ava  2s. c  o m
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

public class Main {
  public static void main(String args[]) throws Exception {
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    JButton button = new JButton("Minimize");
    button.addActionListener(e -> frame.setState(Frame.ICONIFIED));
    frame.add(button);
    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
}