public static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Testing3"); frame.dispose(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new Test3(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }