anecho.gui
Class ColourPicker

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by anecho.gui.ColourPicker
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class ColourPicker
extends java.awt.Dialog
implements java.awt.event.ActionListener, java.awt.event.AdjustmentListener, java.awt.event.KeyListener

A resuable class to allow user selection of RBG colours via three slides, each for their own colour. (plus visual sample) This dialog is for use with Java 1.1

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
ColourPicker(java.awt.Frame frameParent, java.lang.String titleName, java.awt.Color currentColour)
          A resuable class to allow user selection of RBG colours via three slides, each for their own colour.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          This method listens to the buttons, waiting for the user to click Okay or Cancel
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent adj)
          This method listens to our sliders and will automatically update the shown colour as the sliders move.
 java.awt.Color getColour()
          Returns the currently chosen colour.
 java.lang.String getHexColour()
          Return our colour as a Hex-based String
 void keyPressed(java.awt.event.KeyEvent event)
          Empty event
 void keyReleased(java.awt.event.KeyEvent event)
          This method response to the key being released and updates the colour sample as the user types.
 void keyTyped(java.awt.event.KeyEvent event)
          This method response to the key being released and updates the colour sample as the user types.
 void paint(java.awt.Graphics thing)
          Over-ride the paint call to colour our sample box.
 void setVisible(boolean vis)
          Set the colour pick visible or hiden.
 
Methods inherited from class java.awt.Dialog
addNotify, getAccessibleContext, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColourPicker

public ColourPicker(java.awt.Frame frameParent,
                    java.lang.String titleName,
                    java.awt.Color currentColour)
A resuable class to allow user selection of RBG colours via three slides, each for their own colour. (plus visual sample)

Parameters:
frameParent - The parent frame of this dialogue
titleName - Title for the dialogue to be displayed to user.
currentColour - Initial colour to show as selected.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
This method listens to the buttons, waiting for the user to click Okay or Cancel

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - Our MouseEvent

keyReleased

public void keyReleased(java.awt.event.KeyEvent event)
This method response to the key being released and updates the colour sample as the user types.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
event - Our KeyEvent

keyTyped

public void keyTyped(java.awt.event.KeyEvent event)
This method response to the key being released and updates the colour sample as the user types.

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
event - Our KeyEvent

keyPressed

public void keyPressed(java.awt.event.KeyEvent event)
Empty event

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
event - Our event

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent adj)
This method listens to our sliders and will automatically update the shown colour as the sliders move.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Parameters:
adj - Our AdjustmentEvent

paint

public void paint(java.awt.Graphics thing)
Over-ride the paint call to colour our sample box.

Overrides:
paint in class java.awt.Container
Parameters:
thing - The graphics object

setVisible

public void setVisible(boolean vis)
Set the colour pick visible or hiden.

Overrides:
setVisible in class java.awt.Component
Parameters:
vis - true - Set the component visible false - set the component hidden

getColour

public java.awt.Color getColour()
Returns the currently chosen colour.

Returns:
The currently chosen colour as a Java Color object.

getHexColour

public java.lang.String getHexColour()
Return our colour as a Hex-based String

Returns:
Returns a string representing the colour in the HTML-style hex mode.