public JFrame addAppToFrame ( ) { JFrame frame = new JFrame ( ) ; frame . setTitle ( this . getTitle ( ) ) ; frame . setBackground ( Color . lightGray ) ; frame . getContentPane ( ) . setLayout ( new BorderLayout ( ) ) ; frame . getContentPane ( ) . add ( this , BorderLayout . CENTER ) ; frame . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent e ) { System . exit ( 0 ) ; } } ) ; frame . pack ( ) ; frame . setSize ( frame . getPreferredSize ( ) . width , frame . getPreferredSize ( ) . height ) ; return frame ; }
Add this applet to a frame and initialize .