import java.awt.*; import javax.swing.*; /** a first JFrame example that creates a frame instance. Adapted from "Core Java" text, 11th edition, pp. 568-569 @author Cay Horstmann @author adapted by Sharon Tuttle @version 2021-09-20 */ public class SimpleFrameTest { /** creates a simple frame @param args not used here */ public static void main(String[] args) { EventQueue.invokeLater( () -> { SimpleFrame frame = new SimpleFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } ); } } /** A very,very simple frame */ class SimpleFrame extends JFrame { // data fields private static final int DEFAULT_WIDTH = 300; private static final int DEFAULT_HEIGHT = 200; /** construct a simplest frame instance */ public SimpleFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setTitle("My first frame!"); } }