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 classA clean border that visually raises the component above its surroundings.Nested classes/interfaces inherited from class xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
ResizableTextLabel.ResizableAdapterNested classes/interfaces inherited from class javax.swing.JLabel
JLabel.AccessibleJLabelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDOCUMENT ME!static final intDOCUMENT ME!static final intDOCUMENT ME!protected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final intDOCUMENT 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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 TypeMethodDescriptionvoidAdds an action listener to the list of registered listeners for this button.voidDOCUMENT ME!protected voidFires an action event to all its listenersintReturns the currently set action mode.Overriden for rendering purposes.Overriden for rendering purposes.Overriden for rendering purposes.intGets 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.booleanGets the property specifiing whether the button is being pressed.booleanGets the property specifiing whether the mouse is being moved over the button.booleanReturns wether this SimpleButton visually indicates when mouse is over it.protected voidThis method was overloaded to enable advanced graphical features of the SimpleButtonvoidThis method was overloaded to enable advanced graphical features of the SimpleButtonvoidRemoves an action listener from the list of registered listeners for this button.voidDOCUMENT ME!voidsetActionMode(int newMode) Sets the action mode of the SimpleButton.voidsetBackground(Color newColor) Overriden for rendering purposes.voidsetBackgroundStart(Color newColor) Overriden for rendering purposes.voidOverriden for rendering purposes.voidsetFireRate(int newRate) Sets the rate of event firing in the CHAIN_MODEvoidsetForeground(Color newColor) Overriden for rendering purposes.protected voidsetPressed(boolean newPressed) Returns the property specifiing whether the button is being pressed.voidsetPressedBackground(Color newColor) Sets the background color displayed when the button is pressed.voidsetPressedBackgroundStart(Color newColor) Sets the starting background gradient color displayed when the button is pressed.voidsetPressedBorder(Border newBorder) Sets the border displayed when the button is pressed.voidsetPressedForeground(Color newColor) Sets the foreground color displayed when the button is pressed.protected voidsetRollover(boolean newRollover) Sets the property specifiing whether the mouse is being moved over the button.voidsetRolloverBackground(Color newColor) Sets the background color displayed when the mouse cursor is over the button and rollover is enabled.voidsetRolloverBackgroundStart(Color newColor) Sets the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled.voidsetRolloverBorder(Border newBorder) Sets the border displayed when the mouse cursor is over the button and rollover is enabled.voidsetRolloverEnabled(boolean enabled) Enables or disables visual indication when mouse is over this SimpleButton.voidsetRolloverForeground(Color newColor) Sets the foreground color displayed when the mouse cursor is over the button and rollover is enabled.voidsetVisible(boolean visible) DOCUMENT ME!Methods inherited from class xal.extension.widgets.swing.wheelswitch.comp.GradientLabel
isGradientEnabled, setGradientEnabled, setGradientPointsMethods inherited from class xal.extension.widgets.swing.wheelswitch.comp.ResizableTextLabel
getColumns, getMinimumSize, getPreferredSize, isEnhanced, isResizable, resize, setColumns, setEnhanced, setMinimumSize, setPreferredSize, setResizable, setTextMethods 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, updateUIMethods 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, updateMethods 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, validateTreeMethods 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:
setBackgroundin classGradientLabel- Parameters:
newColor- Color- See Also:
-
getBackground
Overriden for rendering purposes.- Overrides:
getBackgroundin classComponent- Returns:
- Color
- See Also:
-
setForeground
Overriden for rendering purposes.- Overrides:
setForegroundin classJComponent- Parameters:
newColor- Color- See Also:
-
getForeground
Overriden for rendering purposes.- Overrides:
getForegroundin classComponent- Returns:
- Color
- See Also:
-
getBackgroundStart
Overriden for rendering purposes.- Overrides:
getBackgroundStartin classGradientLabel- Returns:
- Color
- See Also:
-
setBackgroundStart
Overriden for rendering purposes.- Overrides:
setBackgroundStartin classGradientLabel- Parameters:
newColor- Color- See Also:
-
setBorder
Overriden for rendering purposes.- Overrides:
setBorderin classJComponent- Parameters:
newBorder- Border- See Also:
-
getBorder
Overriden for rendering purposes.- Overrides:
getBorderin 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:
paintComponentin classGradientLabel- Parameters:
g- Graphics- See Also:
-
paintBorder
This method was overloaded to enable advanced graphical features of the SimpleButton- Overrides:
paintBorderin classJComponent- Parameters:
g- Graphics- See Also:
-
addNotify
public void addNotify()DOCUMENT ME!- Overrides:
addNotifyin classResizableTextLabel- See Also:
-
removeNotify
public void removeNotify()DOCUMENT ME!- Overrides:
removeNotifyin classJComponent
-
setVisible
public void setVisible(boolean visible) DOCUMENT ME!- Overrides:
setVisiblein classJComponent- Parameters:
visible- DOCUMENT ME!
-