dsto.dfc.swing.controls
Class ColorChooserCombo

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by dsto.dfc.swing.forms.AbstractFormEditorComponent
                  extended by dsto.dfc.swing.controls.ColorChooserCombo
All Implemented Interfaces:
FormEditor, ActionListener, ImageObserver, MenuContainer, Customizer, PropertyChangeListener, Serializable, EventListener

public class ColorChooserCombo
extends AbstractFormEditorComponent
implements PropertyChangeListener, ActionListener

A JPanel that contains a MetalComboBoxButton which when clicked opens up a ColorChooserPanel. When a color is chosen a property change is fired to alert the parent of a new color.

Version:
$Revision$
Author:
Luke Marsh
See Also:
ColorScheme, ColorSchemePanel, ColorChooserPanel, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ColorChooserPanel colorChooser
           
protected  JPopupMenu colorPopup
           
protected  MetalComboBoxButton comboButton
           
protected  GridBagLayout gridBagLayout1
           
protected  boolean initialize
           
protected  boolean popupShown
           
protected  Color selectedColor
           
protected  String selectedColorName
           
 
Fields inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
description
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
ColorChooserCombo()
          Initializes variables.
 
Method Summary
 void actionPerformed(ActionEvent e)
          When Someone chooses a color on the ColorSchemePanel hide the ColorChooserPanel.
 void commitEdits()
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 Color getColor()
          Get the currently selected Color.
 String getColorName()
          Get the currently selected Color's Name.
 Object getEditorValue()
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 boolean isDirectEdit()
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 void propertyChange(PropertyChangeEvent evt)
          Assigns the event new value to selectedColor.
 void removeNotify()
          Overrides JComponents method and hides this component first.
 void setBackground(Color bg)
          Sets the background color for comboButton.
 void setColor(Color c)
          Set the selected color to c.
 void setColorName(String n)
          Set the selected color's name.
 void setEditorValue(Object value)
          Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor.
 void setEnabled(boolean aFlag)
          Overrides JComponents method, so that we can enable/disable the comboButton.
 void setFont(Font font)
          Sets the font for comboButton.
 void setForeground(Color fg)
          Sets the foreground color for comboButton.
 void setOpaque(boolean isOpaque)
          Sets the opaque property for comboButton.
 void setToolTipText(String text)
          Sets the ToolTipText for comboButton.
 void setVisible(boolean aFlag)
          Overrides JComponents method and hides this component first.
 
Methods inherited from class dsto.dfc.swing.forms.AbstractFormEditorComponent
addFormEditorListener, fireEditComitted, fireEditCommitRequested, fireEditCommitted, getEditorComponent, getEditorDescription, getPreferredValueType, removeFormEditorListener, setEditorDescription, setObject
 
Methods inherited from class javax.swing.JComponent
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, 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, transferFocusBackward, transferFocusDownCycle, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.beans.Customizer
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

popupShown

protected boolean popupShown

initialize

protected boolean initialize

colorPopup

protected JPopupMenu colorPopup

gridBagLayout1

protected GridBagLayout gridBagLayout1

colorChooser

protected ColorChooserPanel colorChooser

selectedColor

protected Color selectedColor

selectedColorName

protected String selectedColorName

comboButton

protected MetalComboBoxButton comboButton
Constructor Detail

ColorChooserCombo

public ColorChooserCombo()
Initializes variables.

Method Detail

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Assigns the event new value to selectedColor.

Specified by:
propertyChange in interface PropertyChangeListener

getColor

public Color getColor()
Get the currently selected Color.


setColor

public void setColor(Color c)
Set the selected color to c. Goes through the default color schemes to check if the color set has an associated name.


getColorName

public String getColorName()
Get the currently selected Color's Name.


setColorName

public void setColorName(String n)
Set the selected color's name.


isDirectEdit

public boolean isDirectEdit()
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. This control is not direct-editable.

Specified by:
isDirectEdit in interface FormEditor
Specified by:
isDirectEdit in class AbstractFormEditorComponent

setEditorValue

public void setEditorValue(Object value)
                    throws IllegalFormatException
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. Sets value to the current Color, and throws an exception if value is not a real Color.

Specified by:
setEditorValue in interface FormEditor
Specified by:
setEditorValue in class AbstractFormEditorComponent
Parameters:
value - The value to display.
Throws:
IllegalFormatException - if the value was not in the correct format for display by this editor. The source specified by the exception should be this FormEditor instance or a child.

getEditorValue

public Object getEditorValue()
                      throws IllegalFormatException
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. Returns the current color.

Specified by:
getEditorValue in interface FormEditor
Specified by:
getEditorValue in class AbstractFormEditorComponent
Throws:
IllegalFormatException

commitEdits

public void commitEdits()
                 throws IllegalFormatException
Implements abstract method in dsto.dfc.swing.forms.AbstractFormEditor. Commit the selection.

Specified by:
commitEdits in interface FormEditor
Overrides:
commitEdits in class AbstractFormEditorComponent
Throws:
IllegalFormatException - if the commit failed because of an illegal input or other error. The source specified by the exception should be the FormEditor instance that caused the error (ie either this editor or a child).

actionPerformed

public void actionPerformed(ActionEvent e)
When Someone chooses a color on the ColorSchemePanel hide the ColorChooserPanel.

Specified by:
actionPerformed in interface ActionListener

setBackground

public void setBackground(Color bg)
Sets the background color for comboButton.

Overrides:
setBackground in class JComponent

setForeground

public void setForeground(Color fg)
Sets the foreground color for comboButton.

Overrides:
setForeground in class JComponent

setFont

public void setFont(Font font)
Sets the font for comboButton.

Overrides:
setFont in class JComponent

setOpaque

public void setOpaque(boolean isOpaque)
Sets the opaque property for comboButton.

Overrides:
setOpaque in class JComponent

setToolTipText

public void setToolTipText(String text)
Sets the ToolTipText for comboButton.

Overrides:
setToolTipText in class JComponent

setEnabled

public void setEnabled(boolean aFlag)
Overrides JComponents method, so that we can enable/disable the comboButton.

Overrides:
setEnabled in class JComponent

setVisible

public void setVisible(boolean aFlag)
Overrides JComponents method and hides this component first.

Overrides:
setVisible in class JComponent

removeNotify

public void removeNotify()
Overrides JComponents method and hides this component first.

Overrides:
removeNotify in class JComponent


Copyright © 2008 Commonwealth of Australia