import java.awt.*; import javax.swing.*; class MyGUI1 { public static void main (String[] args) { JFrame mywindow = new JFrame (); mywindow.setSize (400, 400); mywindow.setTitle ("GUI1 Example"); mywindow.setVisible(true); // To exit from the program by pressing the X button, // the following statement must be included mywindow.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // The easiest way to display a message/result is to // use the JOptionPane class JOptionPane.showMessageDialog (null, "Hello, there!"); // A small computation with result displayed in mywindow int a, b, result; a = 5; b = 9; result = a + b; JOptionPane.showMessageDialog (mywindow, "Next comes the result:"); JOptionPane.showMessageDialog (mywindow, result); JOptionPane.showMessageDialog (null, "Good bye"); } }