Scribble Problem Set Javadocs

cs101.awt
Class DisplayField

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended bycs101.awt.ColorField
              extended bycs101.awt.DisplayField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class DisplayField
extends ColorField

cs101.awt.DisplayField extends cs101.util.ColorField to add a line of text to the colored rectangle.

The size of the rectangle is supposed to change with the length of the text. The color of the field can also change between two predetermined colors.

Copyright 1996 Massachusetts Institute of Technology

Version:
$Id: DisplayField.java,v 1.1.1.1 2002/06/05 21:56:32 root Exp $
Author:
Todd C. Parnell, tparnell@ai.mit.edu, Joshua R. Brown, reuben@ai.mit.edu
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.lang.String text
          the string to be displayed
 
Fields inherited from class cs101.awt.ColorField
dim, falseColor, state, trueColor
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DisplayField(java.lang.String text, boolean initState, java.awt.Color trueColor, java.awt.Color falseColor)
          Constructs a rectangular colorfield with the passed attributes.
 
Method Summary
 void addNotify()
          Calls super.addNotify.
 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)
          Calls the ColorField.paint to do the field.
 void setText(java.lang.String text)
          Changes the text of the DisplayField to the string passed.
 
Methods inherited from class cs101.awt.ColorField
changeState
 
Methods inherited from class java.awt.Canvas
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

text

protected java.lang.String text
the string to be displayed

Constructor Detail

DisplayField

public DisplayField(java.lang.String text,
                    boolean initState,
                    java.awt.Color trueColor,
                    java.awt.Color falseColor)
Constructs a rectangular colorfield with the passed attributes.

Parameters:
text - The text to intially display in the field.
initState - The initial state 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

setText

public void setText(java.lang.String text)
Changes the text of the DisplayField to the string passed. Should also resize the component to fit the text. This is not fully implemented yet.

Parameters:
text - The string to be displayed in the field.

addNotify

public void addNotify()
Calls super.addNotify. Then measures it's intial size.
Note: Must be called from here so that the Font Metrics is available for measuring.


getPreferredSize

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

Overrides:
getPreferredSize in class ColorField
Returns:
the prefered size of the object

getMinimumSize

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

Overrides:
getMinimumSize in class ColorField
Returns:
the minimum size of the object

paint

public void paint(java.awt.Graphics g)
Calls the ColorField.paint to do the field. Then adds the text in black.

Overrides:
paint in class ColorField
Parameters:
g - The graphics context to paint into.

Scribble Problem Set Javadocs