001    /*
002     * Whiteboard.java
003     * Part of the Scribble problem set.
004     *
005     * Developed for "Rethinking CS101", a project of Lynn Andrea Stein's AP Group.
006     * For more information, see http://www.ai.mit.edu/projects/cs101, the
007     * CS101 homepage or email las@ai.mit.edu.
008     *
009     * Copyright (C) 1998 Massachusetts Institute of Technology.
010     * Please do not redistribute without obtaining permission.
011     */
012    
013    package scribble;
014    
015    import java.awt.event.*;
016    import java.awt.*;
017    
018    /**
019     * Whiteboard is the base Frame object.  It sets up the color selector
020     * and clear button, but does not connect them to it's SmartCanvas. 
021     *
022     * <P>Copyright (c) 1998 Massachusetts Institute of Technology
023     *
024     * @author Lynn Andrea Stein, las@ai.mit.edu
025     * @author Todd C. Parnell, tparnell@ai.mit.edu
026     * @version $Id: Whiteboard.java,v 1.2 2004/04/20 15:49:25 gus Exp $
027     *
028     * @see SmartCanvas
029     */
030    public class Whiteboard extends Frame {
031      /** the Canvas users draw on */
032      protected SmartCanvas drawingArea;
033      protected Button clearButton;
034      /** drop down color list */
035      protected Choice colorChoice;
036        
037      /** Constructs a Whiteboard with a new SmartCanvas. */
038      public Whiteboard() {
039        this(new SmartCanvas());
040      }
041    
042      /** 
043       * Constructs a Whiteboard with the given SmartCanvas.  Sets up the
044       * color selector and clear buttons.
045       */
046      public Whiteboard(SmartCanvas drawingArea) {
047        this.drawingArea = drawingArea;
048        this.clearButton = new Button ("Clear");
049            
050        this.colorChoice = new Choice ();
051        this.colorChoice.addItem("Black");
052        this.colorChoice.addItem("Red");
053        this.colorChoice.addItem("Green");
054        this.colorChoice.addItem("Blue");
055        this.colorChoice.addItem("Yellow");
056        this.colorChoice.addItem("Cyan");
057        this.colorChoice.addItem("Magenta");
058        this.colorChoice.addItem("White");
059        this.colorChoice.addItem("Orange");
060        this.colorChoice.addItem("Pink");
061    
062        this.colorChoice.select("Black");
063    
064        this.setTitle("CS101 Scribbler");
065    
066        this.setLayout(new BorderLayout(10, 10)); 
067    
068        // all control widgets go in buttonArea (to simplify layout)
069        Panel buttonArea = new Panel();
070        buttonArea.setLayout(new FlowLayout());
071        buttonArea.add(this.colorChoice);
072        buttonArea.add(this.clearButton);
073    
074        this.add("North", buttonArea);
075        this.add("Center", this.drawingArea);
076    
077        this.addWindowListener(new WindowAdapter() {
078          public void windowClosing(WindowEvent we) {
079            Whiteboard.this.setVisible(false);
080            Whiteboard.this.dispose();
081            System.exit(0);
082          } 
083        });
084    
085        this.pack();
086        this.show();
087      }    
088    }
089        
090    /*
091     * $Log: Whiteboard.java,v $
092     * Revision 1.2  2004/04/20 15:49:25  gus
093     * taking ownership
094     *
095     * Revision 1.1  2003/07/11 16:17:20  jon
096     * Initial commit of spring03 scribble source.
097     *
098     * Revision 1.1.1.1  2002/06/05 21:56:35  root
099     * CS101 comes to Olin finally.
100     *
101     * Revision 1.1  2000/05/06 22:30:58  mharder
102     * Moved to scribble subdirectory.
103     *
104     * Revision 1.5  1998/07/24 16:44:53  tparnell
105     * Placate new javadoc behavior
106     *
107     * Revision 1.4  1998/07/21 19:05:50  tparnell
108     * added more javadoc
109     *
110     * Revision 1.3  1998/07/21 14:09:04  tparnell
111     * minor bugfixes necessary b/c 1.2 complier is more picky
112     *
113     * Revision 1.2  1998/07/20 18:55:33  tparnell
114     * Added javadoc and logging.  Minor code mods for greater consistency
115     * between files.
116     *
117     */
118    
119    
120    
121    
122    
123    
124    
125    
126