Breakout Problem Set Javadocs

Class ColorField

  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended bycs101.awt.ColorField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer,
Direct Known Subclasses:

public class ColorField
extends java.awt.Canvas

cs101.awt.ColorField provides a colored rectangle that operates as an awt.component.

The color field is setup to have two different states represented by two different colors. The field can be of any size or color.

Copyright (c) 1998 Massachusetts Institute of Technolgoy

$Id:,v 2002/06/05 21:56:32 root Exp $
Todd C. Parnell,, Joshua R. Brown,
See Also:
Serialized Form

Nested Class Summary
Nested classes inherited from class java.awt.Canvas
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
Field Summary
protected  java.awt.Dimension dim
          size of the field
protected  java.awt.Color falseColor
          color when state == false
protected  boolean state
          determines the color of the field
protected  java.awt.Color trueColor
          color when state == true
Fields inherited from class java.awt.Component
Fields inherited from interface java.awt.image.ImageObserver
Constructor Summary
          Constructs a rectangular color field with default values for all attibutes.
ColorField(boolean initState, java.awt.Dimension dim, java.awt.Color trueColor, java.awt.Color falseColor)
          Constructs a rectangular colorfield with the passed attributes.
Method Summary
 void changeState(boolean newState)
          Changes the state of the color field to the value passed in.
 java.awt.Dimension getMinimumSize()
          Called by this object's container to determine the minimum space required by this object.
 java.awt.Dimension getPreferredSize()
          Called by this object's container to determine the minimum space required by this object.
 void paint(java.awt.Graphics g)
          Draws the color field on the screen in it's current state
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


protected boolean state
determines the color of the field


protected java.awt.Dimension dim
size of the field


protected java.awt.Color trueColor
color when state == true


protected java.awt.Color falseColor
color when state == false

Constructor Detail


public ColorField()
Constructs a rectangular color field with default values for all attibutes.
o Initial state = false
o Dimension = 25 X 25
o Color when state is true = green
o Color when state is false = red


public ColorField(boolean initState,
                  java.awt.Dimension dim,
                  java.awt.Color trueColor,
                  java.awt.Color falseColor)
Constructs a rectangular colorfield with the passed attributes.

initState - The initial state of the color field.
dim - The dimensions of the color field.
trueColor - The color of the field when the state is true.
falseColor - The color of the field when the state is false.
Method Detail


public void changeState(boolean newState)
Changes the state of the color field to the value passed in. Changing the state of the field will cause the field to repainted in the appropriate color. If the state is unchanged nothing happens.

newState - The new state of the color field.


public void paint(java.awt.Graphics g)
Draws the color field on the screen in it's current state

g - The graphics context to paint into.


public java.awt.Dimension getMinimumSize()
Called by this object's container to determine the minimum space required by this object.

the minimum size of the object


public java.awt.Dimension getPreferredSize()
Called by this object's container to determine the minimum space required by this object.

the prefered size of the object

Breakout Problem Set Javadocs