// Events.java // // Mark F. Hulber // May 1996 // // Events is the top level event handling class for CG Drawing Board. Any // events that it can not handle it sends to the appropriate class. // // import java.awt.*; public class Events extends CG { public Events(String title) { super(title); } public boolean handleEvent(Event event) { switch(event.id){ case Event.ACTION_EVENT: if (event.target == clear){ workarea.handleEvent(event); return false; } else if (event.target == quit) { YesNoDialog d = new ReallyQuitDialog(this, textarea); d.setForeground(Color.white); d.setBackground(Color.black); d.show(); } else if (event.target == about) { InfoDialog d; d = new InfoDialog(this, "CG Drawing Board", "Written by Mark Hulber\n"+ "Copyright(c) 1996"); d.setForeground(Color.white); d.setBackground(Color.black); d.show(); } else if (event.target == algo) { workarea.handleEvent(event); return false; } else { textarea.setText("Unknown action event."); } break; case Event.WINDOW_DESTROY: break; case Event.WINDOW_ICONIFY: break; case Event.WINDOW_DEICONIFY: break; case Event.WINDOW_MOVED: break; case Event.MOUSE_DOWN: return false; case Event.MOUSE_UP: return false; case Event.MOUSE_DRAG: case Event.MOUSE_MOVE: return false; case Event.KEY_PRESS: case Event.KEY_ACTION: return false; case Event.KEY_RELEASE: case Event.KEY_ACTION_RELEASE: return false; case Event.GOT_FOCUS: case Event.LOST_FOCUS: case Event.MOUSE_ENTER: case Event.MOUSE_EXIT: return false; default: textarea.setText("Unexpected Event type:"+event+"\n"); break; } return true; } public static void main(String[] args) { Frame f = new Events("CG Drawing Board 1.0"); f.pack(); f.show(); } }