class WebSample.colorSet extends Component
Each of the buttons is defined as a public field in the inner class, with each field belonging to the class java.awt.Button. The entire panel containing the buttons is also defined as a public field, with the field of type java.awt.Panel.
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
Button |
blackButton
Object for the "black" button.
|
Button |
blueButton
Object for the "blue" button.
|
int |
ColorChoice
Integer value representing the button that
was depressed.
|
(package private) Panel |
colorPanel
Object defining the panel of buttons.
|
Button |
cyanButton
See the description of blackButton
|
Button |
darkGrayButton
See the description of blackButton
|
Button |
grayButton
See the description of blackButton
|
Button |
greenButton
See the description of blackButton
|
Button |
lightGrayButton
See the description of blackButton
|
Button |
magentaButton
See the description of blackButton
|
Button |
orangeButton
See the description of blackButton
|
Button |
pinkButton
See the description of blackButton
|
Button |
redButton
See the description of blackButton
|
private static long |
serialVersionUID |
Button |
whiteButton
See the description of blackButton
|
Button |
yellowButton
See the description of blackButton
|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
WebSample.colorSet()
This is the constructor for the colorSet class
which defines the buttons.
|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, 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, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, 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, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
private static final long serialVersionUID
public int ColorChoice
Panel colorPanel
public Button blackButton
The other buttons are defined in the same manner.
public Button blueButton
The actions in the constructor for blueButton differ from the other in that the label is changed to " Blue " while the message returned to the listener is still "blue".
public Button cyanButton
public Button darkGrayButton
public Button grayButton
public Button lightGrayButton
public Button magentaButton
public Button orangeButton
public Button pinkButton
public Button whiteButton
public Button yellowButton
public Button greenButton
public WebSample.colorSet()
For blackButton, the setLabel and setActionCommand methods are used to set the values.
For the other buttons, label for the button and the message returned when the button is depressed are set equal to the string used in the constructor for the java.awt.Button object.
The add method for the colorPanel object places the various buttons in the panel according to the GridBagLayout and GridBagConstraints classes.