Class SimpleButton
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
xal.extension.widgets.swing.wheelswitch.comp.GradientLabel
xal.extension.widgets.swing.wheelswitch.comp.SimpleButton
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
- Direct Known Subclasses:
ArrowButton
,Digit
A very simple implementation of a button. It supports three action modes
identified by: DEFAULT_ACTION_MODE - the button fires one event when the user
clicks (presses and releases) the left mouse button inside the area of the
button. CHAIN_ACTION_MODE - the button fires one event when the user presses
the left mouse button inside the area of the button and continues firing
events at a constant rate until the user releases the button or moves outside
the button area. NULL_ACTION_MODE - the button fires no events at all.
- Version:
- $id$
- Author:
- Jernej Kamenik
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A clean border that visually raises the component above its surroundings.Nested classes/interfaces inherited from class xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
ResizableTextLabel.ResizableAdapter
Nested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabel
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
FieldsModifier and TypeFieldDescriptionstatic final int
DOCUMENT ME!static final int
DOCUMENT ME!static final int
DOCUMENT ME!protected static final String
protected static final String
protected static final String
protected static final String
static final int
DOCUMENT ME!Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a simple button without text .SimpleButton
(String text) Creates a simple button with text.SimpleButton
(Icon icon) Creates a simple button with Icon. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an action listener to the list of registered listeners for this button.void
DOCUMENT ME!protected void
Fires an action event to all its listenersint
Returns the currently set action mode.Overriden for rendering purposes.Overriden for rendering purposes.Overriden for rendering purposes.int
Gets the rate of event firing in the CHAIN_MODEOverriden for rendering purposes.Gets the background color displayed when the button is pressed.Gets the starting background gradient color displayed when the button is pressed.Gets the border displayed when the button is pressed.Gets the foreground color displayed when the button is pressed.Gets the background color displayed when the mouse cursor is over the button and rollover is enabled.Gets the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled.Gets the border displayed when the mouse cursor is over the button and rollover is enabled.Gets the foreground color displayed when the mouse cursor is over the button and rollover is enabled.boolean
Gets the property specifiing whether the button is being pressed.boolean
Gets the property specifiing whether the mouse is being moved over the button.boolean
Returns wether this SimpleButton visually indicates when mouse is over it.protected void
This method was overloaded to enable advanced graphical features of the SimpleButtonvoid
This method was overloaded to enable advanced graphical features of the SimpleButtonvoid
Removes an action listener from the list of registered listeners for this button.void
DOCUMENT ME!void
setActionMode
(int newMode) Sets the action mode of the SimpleButton.void
setBackground
(Color newColor) Overriden for rendering purposes.void
setBackgroundStart
(Color newColor) Overriden for rendering purposes.void
Overriden for rendering purposes.void
setFireRate
(int newRate) Sets the rate of event firing in the CHAIN_MODEvoid
setForeground
(Color newColor) Overriden for rendering purposes.protected void
setPressed
(boolean newPressed) Returns the property specifiing whether the button is being pressed.void
setPressedBackground
(Color newColor) Sets the background color displayed when the button is pressed.void
setPressedBackgroundStart
(Color newColor) Sets the starting background gradient color displayed when the button is pressed.void
setPressedBorder
(Border newBorder) Sets the border displayed when the button is pressed.void
setPressedForeground
(Color newColor) Sets the foreground color displayed when the button is pressed.protected void
setRollover
(boolean newRollover) Sets the property specifiing whether the mouse is being moved over the button.void
setRolloverBackground
(Color newColor) Sets the background color displayed when the mouse cursor is over the button and rollover is enabled.void
setRolloverBackgroundStart
(Color newColor) Sets the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled.void
setRolloverBorder
(Border newBorder) Sets the border displayed when the mouse cursor is over the button and rollover is enabled.void
setRolloverEnabled
(boolean enabled) Enables or disables visual indication when mouse is over this SimpleButton.void
setRolloverForeground
(Color newColor) Sets the foreground color displayed when the mouse cursor is over the button and rollover is enabled.void
setVisible
(boolean visible) DOCUMENT ME!Methods inherited from class xal.extension.widgets.swing.wheelswitch.comp.GradientLabel
isGradientEnabled, setGradientEnabled, setGradientPoints
Methods inherited from class xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
getColumns, getMinimumSize, getPreferredSize, isEnhanced, isResizable, resize, setColumns, setEnhanced, setMinimumSize, setPreferredSize, setResizable, setText
Methods inherited from class javax.swing.JLabel
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintImmediately, paintImmediately, 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, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
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, 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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
MOUSE_PRESSED
- See Also:
-
MOUSE_CLICKED
- See Also:
-
MOUSE_RELEASED
- See Also:
-
MOUSE_CHAIN
- See Also:
-
NULL_ACTION_MODE
public static final int NULL_ACTION_MODEDOCUMENT ME!- See Also:
-
DEFAULT_ACTION_MODE
public static final int DEFAULT_ACTION_MODEDOCUMENT ME!- See Also:
-
CHAIN_ACTION_MODE
public static final int CHAIN_ACTION_MODEDOCUMENT ME!- See Also:
-
FAST_ACTION_MODE
public static final int FAST_ACTION_MODEDOCUMENT ME!- See Also:
-
-
Constructor Details
-
SimpleButton
Creates a simple button with text.- Parameters:
text
- java.lang.String to be displayed on the button.
-
SimpleButton
Creates a simple button with Icon.- Parameters:
icon
- javax.swing.Icon to be displayed on the button.
-
SimpleButton
public SimpleButton()Creates a simple button without text .
-
-
Method Details
-
setActionMode
public void setActionMode(int newMode) Sets the action mode of the SimpleButton. DEFAULT_ACTION_MODE fires ActionEvent when left mouse button is clicked. CHAIN_ACTION_MODE fires a series of ActionEvent while left mouse button is being pressed at thefireRate
. FAST_ACTION_MODE fires ActionEvent when left mouse button is pressed. NULL_ACTION_MODE fires no ActionEvents on mouse actions but pressing the ENTER key still triggers ActionEvents.- Parameters:
newMode
- to be set.- Throws:
IllegalArgumentException
- if the value entered is not one of DEFAULT_ACTION_MODE, CHAIN_ACTION_MODE, FAST_ACTION_MODE or NULL_ACTION_MODE.
-
getActionMode
public int getActionMode()Returns the currently set action mode.- Returns:
- int used action mode.
-
setBackground
Overriden for rendering purposes.- Overrides:
setBackground
in classGradientLabel
- Parameters:
newColor
- Color- See Also:
-
getBackground
Overriden for rendering purposes.- Overrides:
getBackground
in classComponent
- Returns:
- Color
- See Also:
-
setForeground
Overriden for rendering purposes.- Overrides:
setForeground
in classJComponent
- Parameters:
newColor
- Color- See Also:
-
getForeground
Overriden for rendering purposes.- Overrides:
getForeground
in classComponent
- Returns:
- Color
- See Also:
-
getBackgroundStart
Overriden for rendering purposes.- Overrides:
getBackgroundStart
in classGradientLabel
- Returns:
- Color
- See Also:
-
setBackgroundStart
Overriden for rendering purposes.- Overrides:
setBackgroundStart
in classGradientLabel
- Parameters:
newColor
- Color- See Also:
-
setBorder
Overriden for rendering purposes.- Overrides:
setBorder
in classJComponent
- Parameters:
newBorder
- Border- See Also:
-
getBorder
Overriden for rendering purposes.- Overrides:
getBorder
in classJComponent
- Returns:
- Border
- See Also:
-
getPressedBackground
Gets the background color displayed when the button is pressed.- Returns:
- Color
-
setPressedBackground
Sets the background color displayed when the button is pressed.- Parameters:
newColor
- Color
-
getPressedForeground
Gets the foreground color displayed when the button is pressed.- Returns:
- Color
-
setPressedForeground
Sets the foreground color displayed when the button is pressed.- Parameters:
newColor
- Color
-
getPressedBackgroundStart
Gets the starting background gradient color displayed when the button is pressed.- Returns:
- Color
-
setPressedBackgroundStart
Sets the starting background gradient color displayed when the button is pressed.- Parameters:
newColor
- Color
-
getPressedBorder
Gets the border displayed when the button is pressed.- Returns:
- Border
-
setPressedBorder
Sets the border displayed when the button is pressed.- Parameters:
newBorder
- Border
-
getRolloverBackground
Gets the background color displayed when the mouse cursor is over the button and rollover is enabled.- Returns:
- Color
-
setRolloverBackground
Sets the background color displayed when the mouse cursor is over the button and rollover is enabled.- Parameters:
newColor
- Color
-
getRolloverForeground
Gets the foreground color displayed when the mouse cursor is over the button and rollover is enabled.- Returns:
- Color
-
setRolloverForeground
Sets the foreground color displayed when the mouse cursor is over the button and rollover is enabled.- Parameters:
newColor
- Color
-
getRolloverBackgroundStart
Gets the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled.- Returns:
- Color
-
setRolloverBackgroundStart
Sets the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled.- Parameters:
newColor
- Color
-
getRolloverBorder
Gets the border displayed when the mouse cursor is over the button and rollover is enabled.- Returns:
- Border
-
setRolloverBorder
Sets the border displayed when the mouse cursor is over the button and rollover is enabled.- Parameters:
newBorder
- Border
-
setRolloverEnabled
public void setRolloverEnabled(boolean enabled) Enables or disables visual indication when mouse is over this SimpleButton.- Parameters:
enabled
- boolean whether this SimpleButton should indicate when mouse is over it.
-
isRolloverEnabled
public boolean isRolloverEnabled()Returns wether this SimpleButton visually indicates when mouse is over it.- Returns:
- boolean true if rollover indication is enabled, false otherwise.
-
setFireRate
public void setFireRate(int newRate) Sets the rate of event firing in the CHAIN_MODE- Parameters:
newRate
- int time in miliseconds between successive events are fired.
-
getFireRate
public int getFireRate()Gets the rate of event firing in the CHAIN_MODE- Returns:
- int
-
isPressed
public boolean isPressed()Gets the property specifiing whether the button is being pressed.- Returns:
- boolean
-
setPressed
protected void setPressed(boolean newPressed) Returns the property specifiing whether the button is being pressed.- Parameters:
newPressed
- boolean
-
isRollover
public boolean isRollover()Gets the property specifiing whether the mouse is being moved over the button.- Returns:
- boolean
-
setRollover
protected void setRollover(boolean newRollover) Sets the property specifiing whether the mouse is being moved over the button.- Parameters:
newRollover
- boolean
-
fireActionPerformed
Fires an action event to all its listeners- Parameters:
e
- ActionEvent
-
addActionListener
Adds an action listener to the list of registered listeners for this button.- Parameters:
l
- ActionListener
-
removeActionListener
Removes an action listener from the list of registered listeners for this button.- Parameters:
l
- ActionListener
-
paintComponent
This method was overloaded to enable advanced graphical features of the SimpleButton- Overrides:
paintComponent
in classGradientLabel
- Parameters:
g
- Graphics- See Also:
-
paintBorder
This method was overloaded to enable advanced graphical features of the SimpleButton- Overrides:
paintBorder
in classJComponent
- Parameters:
g
- Graphics- See Also:
-
addNotify
public void addNotify()DOCUMENT ME!- Overrides:
addNotify
in classResizableTextLabel
- See Also:
-
removeNotify
public void removeNotify()DOCUMENT ME!- Overrides:
removeNotify
in classJComponent
-
setVisible
public void setVisible(boolean visible) DOCUMENT ME!- Overrides:
setVisible
in classJComponent
- Parameters:
visible
- DOCUMENT ME!
-