import java.awt.*; import javax.swing.*; class MyGUI2 { public static void main (String[] args) { JFrame mywindow = new JFrame (); mywindow.setTitle ("GUI2 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); JPanel mypanel = new JPanel (); mypanel.setPreferredSize (new Dimension (400, 400)); mypanel.setBackground (Color.yellow); JLabel label1 = new JLabel ("Hello, there ..."); JLabel label2 = new JLabel ("... and good bye"); mypanel.add(label1); mypanel.add(label2); mywindow.getContentPane().add(mypanel); mywindow.pack(); } }