com.sygem.swing.jpopupslider
Class JPopupSlider

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.sygem.swing.jpopupslider.JPopupSlider
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JPopupSlider
extends javax.swing.JPanel
implements java.io.Serializable

The main class of the JPopupSlider component.

Title: JPopupSlider
Description: Displays a slider bar in a popup window
Copyright: Copyright (c) 2004
Company: SyGem Software

Version:
1.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int DIRECTION_DOWN
          Draws the direction arrow pointing downwards
static int DIRECTION_LEFT
          Draws the direction arrow pointing to the left
static int DIRECTION_RIGHT
          Draws the direction arrow pointing to the right
static int DIRECTION_UP
          Draws the direction arrow pointing upwards (default)
static int FULL_UP
          Popup window will always be placed at the same position
static int PARTIAL_UP
          Popup slider will be drawn level with the mouse pointer (default)
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
JPopupSlider()
          Constructs a new JPopupSlider with default values.
JPopupSlider(double value, double minvalue, double maxvalue, double step)
          Constructs a new JPopupSlider with initial (double) values.
JPopupSlider(int value, int minvalue, int maxvalue, int step)
          Constructs a new JPopupSlider with initial (integer) values.
JPopupSlider(PopupNumberModel model)
          Constructs a new JPopupSlider based on the PopupNumberModel.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds an ActionListener - listens for when the button has been pressed.
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Adds a ChangeListener - listens for when the value changes.
 java.awt.event.ActionListener[] getActionListeners()
          Returns an array containing the ActionListeners registered against this popup slider.
 java.awt.Color getBarColor()
          Returns the Color used to draw the popup slider bar.
 javax.swing.event.ChangeListener[] getChangeListeners()
          Returns an array containing the ChangeListeners registered against this popup slider.
 int getDirection()
          Returns the direction that the popup slider will appear, relative to the button.
 javax.swing.border.Border getDisabledBorder()
          Returns the border used when the button is disabled.
 javax.swing.border.Border getLoweredBorder()
          Returns the border used when the button is active and has been clicked on.
 PopupNumberModel getModel()
          Returns the model used for controlling the values of this popup sider.
 int getPopupHeight()
          Returns the height of the popup slider window
 int getPopupMode()
          Returns the popup mode of the slider.
 java.awt.Color getPopupOutlineColor()
          Returns the Color used to outline the popup slider window.
 int getPopupWidth()
          Returns the width of the popup slider window
 javax.swing.border.Border getRaisedBorder()
          Returns the border used when the button is active, but has not been clicked on.
 java.lang.Object getValue()
          Gets the current value of this slider.
 boolean getValueIsUpdating()
          Returns true if the value of the slider is currently being changed.
 void paintComponent(java.awt.Graphics g)
          Overriden to enable the drawing of the direction arrow.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes an ActionListener.
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes a ChangeListener.
 void setBarColor(java.awt.Color barColor)
          Sets the color used to draw the bar indicating the slider value.
 void setDirection(int dir)
          Sets the direction that the popup slider will appear, relative to the button.
 void setDisabledBorder(javax.swing.border.Border disabledBorder)
          Sets the border to be shown when the button is disabled.
 void setEnabled(boolean enabled)
          Sets whether or not this component is enabled.
 void setLoweredBorder(javax.swing.border.Border loweredBorder)
          Sets the border to be shown when the button is active and has been clicked on.
 void setModel(PopupNumberModel newModel)
          Sets the PopupNumberModel used to control this popup slider.
 void setPopupHeight(int h)
          Sets the height of the popup slider window.
 void setPopupMode(int m)
          Sets the popup mode of the slider.
 void setPopupOutlineColor(java.awt.Color outlineColor)
          Sets the color used to outline the popup window.
 void setPopupWidth(int w)
          Sets the width of the popup slider window.
 void setRaisedBorder(javax.swing.border.Border raisedBorder)
          Sets the border to be shown when the button is active, but not clicked on.
 void setValue(java.lang.Object value)
          Sets the value of this popup slider.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIRECTION_DOWN

public static final int DIRECTION_DOWN
Draws the direction arrow pointing downwards

See Also:
Constant Field Values

DIRECTION_LEFT

public static final int DIRECTION_LEFT
Draws the direction arrow pointing to the left

See Also:
Constant Field Values

DIRECTION_RIGHT

public static final int DIRECTION_RIGHT
Draws the direction arrow pointing to the right

See Also:
Constant Field Values

DIRECTION_UP

public static final int DIRECTION_UP
Draws the direction arrow pointing upwards (default)

See Also:
Constant Field Values

FULL_UP

public static final int FULL_UP
Popup window will always be placed at the same position

See Also:
Constant Field Values

PARTIAL_UP

public static final int PARTIAL_UP
Popup slider will be drawn level with the mouse pointer (default)

See Also:
Constant Field Values
Constructor Detail

JPopupSlider

public JPopupSlider()
Constructs a new JPopupSlider with default values.


JPopupSlider

public JPopupSlider(double value,
                    double minvalue,
                    double maxvalue,
                    double step)
Constructs a new JPopupSlider with initial (double) values.

Parameters:
value - Inital value for the slider
minvalue - Minimum value
maxvalue - Maximum value
step - Distance at which to draw step marks on the popup window

JPopupSlider

public JPopupSlider(int value,
                    int minvalue,
                    int maxvalue,
                    int step)
Constructs a new JPopupSlider with initial (integer) values.

Parameters:
value - Inital value for the slider
minvalue - Minimum value
maxvalue - Maximum value
step - Distance at which to draw step marks on the popup window

JPopupSlider

public JPopupSlider(PopupNumberModel model)
Constructs a new JPopupSlider based on the PopupNumberModel.

Parameters:
model - PopupNumberModel
See Also:
PopupNumberModel
Method Detail

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds an ActionListener - listens for when the button has been pressed.

Parameters:
listener - The ActionListener to add

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a ChangeListener - listens for when the value changes.

Parameters:
listener - The ChangeListener to add

getActionListeners

public java.awt.event.ActionListener[] getActionListeners()
Returns an array containing the ActionListeners registered against this popup slider.

Returns:
An array of ActionListeners, which may be empty

getBarColor

public java.awt.Color getBarColor()
Returns the Color used to draw the popup slider bar.

Returns:
The current slider bar Color

getChangeListeners

public javax.swing.event.ChangeListener[] getChangeListeners()
Returns an array containing the ChangeListeners registered against this popup slider.

Returns:
An array of ChangeListeners, which may be empty

getDirection

public int getDirection()

Returns the direction that the popup slider will appear, relative to the button.

Returns:
the direction of this popup slider
See Also:
setDirection(int)

getDisabledBorder

public javax.swing.border.Border getDisabledBorder()
Returns the border used when the button is disabled.

Returns:
The Disabled Border

getLoweredBorder

public javax.swing.border.Border getLoweredBorder()
Returns the border used when the button is active and has been clicked on.

Returns:
The Lowered Border

getModel

public PopupNumberModel getModel()
Returns the model used for controlling the values of this popup sider.

Returns:
PopupNumberModel

getPopupHeight

public int getPopupHeight()
Returns the height of the popup slider window

Returns:
the popup slider window height

getPopupMode

public int getPopupMode()

Returns the popup mode of the slider.

Returns:
int
See Also:
setPopupMode(int)

getPopupOutlineColor

public java.awt.Color getPopupOutlineColor()
Returns the Color used to outline the popup slider window.

Returns:
The current popup outine Color

getPopupWidth

public int getPopupWidth()
Returns the width of the popup slider window

Returns:
the popup slider window width

getRaisedBorder

public javax.swing.border.Border getRaisedBorder()
Returns the border used when the button is active, but has not been clicked on.

Returns:
The Raised Border

getValue

public java.lang.Object getValue()
Gets the current value of this slider.

Returns:
A Number, usually an Integer or Double.

getValueIsUpdating

public boolean getValueIsUpdating()
Returns true if the value of the slider is currently being changed.

Returns:
True if the popup window is visible

paintComponent

public void paintComponent(java.awt.Graphics g)
Overriden to enable the drawing of the direction arrow.

Parameters:
g - The Graphics context to which we draw the arrow

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes an ActionListener.

Parameters:
listener - The ActionListener to remove

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a ChangeListener.

Parameters:
listener - The ChangeListener to remove

setBarColor

public void setBarColor(java.awt.Color barColor)
Sets the color used to draw the bar indicating the slider value.

Parameters:
barColor - The bar color

setDirection

public void setDirection(int dir)

Sets the direction that the popup slider will appear, relative to the button.

Valid values are:


The direction also changes the orientation of the arrow drawn on the button.

Parameters:
dir - The direction for this popup slider

setDisabledBorder

public void setDisabledBorder(javax.swing.border.Border disabledBorder)
Sets the border to be shown when the button is disabled.

Parameters:
disabledBorder - The new Disabled Border

setEnabled

public void setEnabled(boolean enabled)
Sets whether or not this component is enabled.

Parameters:
enabled - true if this component should be enabled, false otherwise

setLoweredBorder

public void setLoweredBorder(javax.swing.border.Border loweredBorder)
Sets the border to be shown when the button is active and has been clicked on.

Parameters:
loweredBorder - The new Lowered Border

setModel

public void setModel(PopupNumberModel newModel)
Sets the PopupNumberModel used to control this popup slider.

Parameters:
newModel - A PopupNumberModel

setPopupHeight

public void setPopupHeight(int h)

Sets the height of the popup slider window.

NOTE: if direction is either DIRECTION_LEFT or DIRECTION_RIGHT, this actually sets the width of the popup window.

Parameters:
h - The height of the popup window

setPopupMode

public void setPopupMode(int m)

Sets the popup mode of the slider.

Valid values are:

Parameters:
m - Popup mode

setPopupOutlineColor

public void setPopupOutlineColor(java.awt.Color outlineColor)
Sets the color used to outline the popup window.

Parameters:
outlineColor - The outline color for the popup window

setPopupWidth

public void setPopupWidth(int w)

Sets the width of the popup slider window.

NOTE: if direction is either DIRECTION_LEFT or DIRECTION_RIGHT, this actually sets the height of the popup window.

Parameters:
w - The width of the popup window

setRaisedBorder

public void setRaisedBorder(javax.swing.border.Border raisedBorder)
Sets the border to be shown when the button is active, but not clicked on.

Parameters:
raisedBorder - The new Raised Border

setValue

public void setValue(java.lang.Object value)
Sets the value of this popup slider. Must be a Number object.

Parameters:
value - The new value for the slider


Copyright © 2004 SyGem Software. All Rights Reserved.