private static void createAndShowGUI ( GUIAlignmentProgressListener progressListener ) { //Create and set up the window. JFrame frame = new JFrame ( "Monitor alignment process" ) ; frame . setDefaultCloseOperation ( JFrame . EXIT_ON_CLOSE ) ; //Create and set up the content pane. JComponent newContentPane = progressListener ; newContentPane . setOpaque ( true ) ; //content panes must be opaque newContentPane . setSize ( new Dimension ( 400 , 400 ) ) ; frame . setContentPane ( newContentPane ) ; //Display the window. frame . pack ( ) ; frame . setVisible ( true ) ; }
Create the GUI and show it . As with all GUI code this must run on the event - dispatching thread .