public class Door
extends javax.swing.JComponent
implements java.io.Serializable
javax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static int |
CAR |
static int |
GOAT |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
Door()
This default constructor creates a new door with default
size 150 by 200 and with default door color yellow,
open color white, and label color red.
|
Door(int w,
int h)
This special constructor creates a new door with specified
height and width and with default door color yellow, open
color white, and label color red.
|
Door(int w,
int h,
java.awt.Color dc,
java.awt.Color oc,
java.awt.Color lc)
This general constructor creates a new door with width and height, and
specified colors.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(java.lang.String s)
This method closes the door to display a specified caption.
|
java.awt.Color |
getDoorColor()
This method returns the door color
|
java.awt.Image |
getImage()
This method returns the image.
|
java.lang.String |
getLabel()
This method returns the label.
|
java.awt.Color |
getLabelColor()
This method returns the label color
|
java.awt.Dimension |
getMinimumSize()
This method specifies the minimum size.
|
java.awt.Color |
getOpenColor()
This method returns the open color
|
java.awt.Dimension |
getPreferredSize()
This method specifies the preferred size.
|
boolean |
isOpened()
This method tests to see if the door is opened.
|
void |
open(java.awt.Image i,
java.lang.String s)
This method opens the door to display a specified image and caption.
|
void |
open(int i,
java.lang.String s)
This method opens the door to display one of the standard images
(the car or the goat) and a caption
|
void |
paintComponent(java.awt.Graphics g)
This method paints the door.
|
void |
setDoorColor(java.awt.Color c)
This method sets the door color.
|
void |
setImage(java.awt.Image i)
This method sets the image.
|
void |
setImage(int i)
This method sets the image to one of the standard images (car or goat).
|
void |
setLabel(java.lang.String s)
This method sets the label.
|
void |
setLabelColor(java.awt.Color c)
This method sets the label color.
|
void |
setOpenColor(java.awt.Color c)
This method sets the open color.
|
void |
setOpened(boolean b)
This method set the open state of the door.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final int GOAT
public static final int CAR
public Door(int w,
int h,
java.awt.Color dc,
java.awt.Color oc,
java.awt.Color lc)
w - the widthh - the heightdc - door coloroc - open colorlc - label colorpublic Door(int w,
int h)
w - the widthh - the heightpublic Door()
public void open(java.awt.Image i,
java.lang.String s)
i - the images - the labelpublic void open(int i,
java.lang.String s)
i - the index (0 goat, 1 car)s - the captionpublic void close(java.lang.String s)
s - the label.public void setImage(java.awt.Image i)
i - the imagepublic void setImage(int i)
public java.awt.Image getImage()
public void setLabel(java.lang.String s)
s - the stringpublic java.lang.String getLabel()
public void paintComponent(java.awt.Graphics g)
paintComponent in class javax.swing.JComponentg - the graphics context.public void setOpened(boolean b)
b - true if the door is to be openedpublic boolean isOpened()
public void setDoorColor(java.awt.Color c)
c - the door colorpublic java.awt.Color getDoorColor()
public void setOpenColor(java.awt.Color c)
c - the open colorpublic java.awt.Color getOpenColor()
public void setLabelColor(java.awt.Color c)
c - the label colorpublic java.awt.Color getLabelColor()
public java.awt.Dimension getMinimumSize()
getMinimumSize in class javax.swing.JComponentpublic java.awt.Dimension getPreferredSize()
getPreferredSize in class javax.swing.JComponent