import javax.swing.*; import java.awt.*; class Ex1 { // Screen is divided into many pixels // Pixel is a unit of drawing final static int XPIXELS = 800; final static int YPIXELS = 600; public static void main(String[] args) { // JFrame is a predefined class JFrame jf = new JFrame("Example-1 in Java GUI"); // What to do when window is closed? jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set the size of the window (in terms of pixels) jf.setSize(new Dimension(XPIXELS, YPIXELS)); // Show the frame jf.setVisible(true); // Note: main does not exit here } // End main() }