// This is how I do it. I subclass SCView, then override whichever // event driven methods in the subclass. Use addWidget(String,Component) // instead of add(Component) to add widgets, then you can talk to // them later with getWidget(String). Subviews are here to support opening // additional Frames (SCView's) under the original main thread, keeping track // of those Frames, and talking to them arbitrarily with getSubview(String). import java.awt.*; import java.awt.event.*; import java.util.*; public class SCView extends Frame implements KeyListener, Observer, WindowListener, ActionListener, MouseListener, ItemListener { private Hashtable widgets_; private void widgets(Hashtable aHashtable) { widgets_ = aHashtable; } private Hashtable widgets() { return widgets_; } private Hashtable subViews_; private void subViews(Hashtable aHashtable) { subViews_ = aHashtable; } private Hashtable subViews() { return subViews_; } public SCView(String s){ super(s); this.initialize(); } private void initialize(){ this.widgets( new Hashtable() ); this.subViews( new Hashtable() ); this.setLayout(null); this.addWindowListener(this); } public void addWidget(String aName, Component c){ this.add(c); this.widgets().put(aName, c); } public Component getWidget(String aName){ return (Component) this.widgets().get(aName); } public void addSubView(String aName, SCView v){ this.subViews().put(aName, v); } public Component getSubView(String aName){ return (SCView) this.subViews().get(aName); } public void removeWidget( Object o ){ this.remove(this.getWidget((String) o)); this.widgets().remove( o ); } // support Observer interface public void update(Observable obs, Object o){} // support ActionListener interface public void actionPerformed(ActionEvent e){} // support WindowListener interface public void windowActivated (WindowEvent e){} public void windowClosed (WindowEvent e){} public void windowClosing (WindowEvent e){} public void windowOpened (WindowEvent e){} public void windowDeactivated (WindowEvent e){} public void windowIconified (WindowEvent e){} public void windowDeiconified (WindowEvent e){} // support MouseListener interface public void mouseClicked ( MouseEvent me ){} public void mouseEntered ( MouseEvent me ){} public void mouseExited ( MouseEvent me ){} public void mousePressed ( MouseEvent me ){} public void mouseReleased ( MouseEvent me ){} // support ItemListener interface public void itemStateChanged( ItemEvent ie ){} // support KeyListener interface public void keyPressed (KeyEvent ke){} public void keyReleased (KeyEvent ke){} public void keyTyped (KeyEvent ke){} }