import javax.swing.*; import java.awt.*; import java.awt.event.*; // subclasses should add all components desired and then setVisible (true); public class EFrame extends JFrame { private Container itsContent; public EFrame(String title, int width, int height, boolean isMain) { super (title); // put the title on it if (isMain) this.addWindowListener (new Closer()); // enable closing this.setSize (width, height); // measured in pixels itsContent = this.getContentPane(); itsContent.setLayout (new FlowLayout()); itsContent.setBackground (Color.white); } //====================== public EFrame() { this ("", 700, 600, true); // use the constructor above } //====================== public Component add (Component given) { itsContent.add (given); return this; } //====================== public void startNewRow() { JPanel jp = new JPanel(); jp.setPreferredSize (new Dimension (2000, 2)); jp.setBackground (itsContent.getBackground()); itsContent.add (jp); } //====================== public static class Closer implements WindowListener { /** Enable the closer icon to terminate the program. */ public void windowClosing (WindowEvent ev) { System.exit (0); } //====================== public void windowActivated (WindowEvent ev) { } public void windowDeactivated (WindowEvent ev) { } public void windowIconified (WindowEvent ev) { } public void windowDeiconified (WindowEvent ev) { } public void windowOpened (WindowEvent ev) { } public void windowClosed (WindowEvent ev) { } } }