// purpose: provide JFrames with appropriate characteristics import javax.swing.*; import java.awt.*; public class Window { // make(): return a new window with characteristics // title s background color c // width w whether on top t // height h whether visible v public static JFrame make( String s, int w, int h, Color c, boolean t, boolean v ) { JFrame window = new JFrame( s ); window.setSize( w, h ); window.getContentPane().setBackground( c ); window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); window.setLayout( new FlowLayout() ); window.setAlwaysOnTop( t ); window.setVisible( v ); return window; } // make(): return a new window with characteristics // title s background color black // picture p on top // visible public static JFrame make( String s, ImageIcon p ) { JFrame window = new JFrame( s ); int w = p.getIconWidth() + 4; int h = p.getIconHeight() + 16; window.setSize( w, h ); window.add( new JLabel( p ) ); window.getContentPane().setBackground( Color.BLACK ); window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); window.setAlwaysOnTop( true ); window.setVisible( true ); return window; } }