001 /* 002 * BetterBoard.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 import cs101.util.Coerce; 018 019 /** 020 * BetterBoard connects the Whiteboard's clear and color selector GUI 021 * elements to the ScribbleCanvas. As opposed to Whiteboard, the 022 * clear button and the color selector actually work as you might 023 * expect. 024 * 025 * <P>Copyright (c) 1998 Massachusetts Institute of Technology 026 * 027 * @author Lynn Andrea Stein, las@ai.mit.edu 028 * @author Todd C. Parnell, tparnell@ai.mit.edu 029 * @version $Id: BetterBoard.java,v 1.4 2003/03/28 16:55:04 gus Exp $ 030 */ 031 public class BetterBoard extends Whiteboard { 032 033 /** Constructs a BetterBoard with a new SmartCanvas. */ 034 public BetterBoard() { 035 this(new ScribbleCanvas()); 036 } 037 038 /** 039 * Constructs a BetterBoard with with given SmartCanvas. Connects 040 * the color selector and clear buttons to the SmartCanvas. 041 */ 042 public BetterBoard(ScribbleCanvas myScribbleCanvas) { 043 super(myScribbleCanvas); 044 045 this.clearButton.addActionListener(new ActionListener() { 046 public void actionPerformed(ActionEvent ae) { 047 ((ScribbleCanvas)drawingArea).clearLines(); 048 } 049 }); 050 this.colorChoice.addItemListener(new ItemListener() { 051 public void itemStateChanged(ItemEvent ie) { 052 ((ScribbleCanvas)drawingArea).setColor(Coerce.stringToColor 053 (colorChoice.getSelectedItem())); 054 } 055 }); 056 } 057 } 058 059 /* 060 * $Log: BetterBoard.java,v $ 061 * Revision 1.4 2003/03/28 16:55:04 gus 062 * new name for Coerce method 063 * 064 * Revision 1.3 2003/02/26 22:14:05 gus 065 * Reformat 066 * 067 * Revision 1.2 2003/02/26 22:12:02 gus 068 * Made the import statements specific rather than using *'s 069 * 070 * Revision 1.1.1.1 2002/06/05 21:56:35 root 071 * CS101 comes to Olin finally. 072 * 073 * Revision 1.1 2000/05/06 22:30:57 mharder 074 * Moved to scribble subdirectory. 075 * 076 * Revision 1.5 1998/07/24 16:44:50 tparnell 077 * Placate new javadoc behavior 078 * 079 * Revision 1.4 1998/07/21 14:09:03 tparnell 080 * minor bugfixes necessary b/c 1.2 complier is more picky 081 * 082 * Revision 1.3 1998/07/20 18:55:31 tparnell 083 * Added javadoc and logging. Minor code mods for greater consistency 084 * between files. 085 * 086 */