|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JLabel com.cosylab.gui.components.ResizableTextLabel com.cosylab.gui.components.GradientLabel com.cosylab.gui.components.SimpleButton
public class SimpleButton
A very simple implementation of a button. It supports three action modes identified by:
FAST_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.
GradientLabel
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class com.cosylab.gui.components.ResizableTextLabel |
---|
ResizableTextLabel.ResizableAdapter |
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
javax.swing.JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
CHAIN_ACTION_MODE
Events are fired continuously until mouse button is released. |
static int |
DEFAULT_ACTION_MODE
One event is fired for one click. |
static int |
FAST_ACTION_MODE
One event is fired for one click. |
protected static java.lang.String |
MOUSE_CHAIN
|
protected static java.lang.String |
MOUSE_CLICKED
|
protected static java.lang.String |
MOUSE_PRESSED
|
protected static java.lang.String |
MOUSE_RELEASED
|
static int |
NULL_ACTION_MODE
No events are fired. |
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 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 |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
SimpleButton()
Creates a simple button without text . |
|
SimpleButton(javax.swing.Icon icon)
Creates a simple button with Icon. |
|
SimpleButton(java.lang.String text)
Creates a simple button with text. |
Method Summary | |
---|---|
void |
addActionListener(java.awt.event.ActionListener l)
Adds an action listener to the list of registered listeners for this button. |
void |
addNotify()
This method was overriden to implement font resizing. |
protected void |
fireActionPerformed(java.awt.event.ActionEvent e)
Fires an action event to all its listeners |
int |
getActionMode()
Returns the currently set action mode. |
java.awt.Color |
getBackground()
|
java.awt.Color |
getBackgroundStart()
Returns the backgroundStart, this is the color that is used for the start of label's gradient. |
javax.swing.border.Border |
getBorder()
|
int |
getFireRate()
Gets the rate of event firing in the CHAIN_MODE |
java.awt.Color |
getForeground()
|
java.awt.Color |
getPressedBackground()
Returns the background color displayed when the button is pressed. |
java.awt.Color |
getPressedBackgroundStart()
Returns the starting background gradient color displayed when the button is pressed. |
javax.swing.border.Border |
getPressedBorder()
Returns the border displayed when the button is pressed. |
java.awt.Color |
getPressedForeground()
Returns the foreground color displayed when the button is pressed. |
java.awt.Color |
getRolloverBackground()
Returns the background color displayed when the mouse cursor is over the button and rollover is enabled. |
java.awt.Color |
getRolloverBackgroundStart()
Returns the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled. |
javax.swing.border.Border |
getRolloverBorder()
Returns the border displayed when the mouse cursor is over the button and rollover is enabled. |
java.awt.Color |
getRolloverForeground()
Returns the foreground color displayed when the mouse cursor is over the button and rollover is enabled. |
boolean |
isPressed()
Gets the property specifiing whether the button is being pressed. |
boolean |
isRollover()
Gets the property specifiing whether the mouse is being moved over the button. |
boolean |
isRolloverEnabled()
Returns wether this SimpleButton visually indicates when mouse is over it. |
static void |
main(java.lang.String[] args)
Run test applet. |
protected void |
paintBorder(java.awt.Graphics g)
This method was overloaded to enable advanced graphical features of the SimpleButton |
void |
paintComponent(java.awt.Graphics g)
This method was overloaded to enable advanced graphical features of the SimpleButton |
void |
removeActionListener(java.awt.event.ActionListener l)
Removes an action listener from the list of registered listeners for this button. |
void |
removeNotify()
|
void |
setActionMode(int newMode)
Sets the action mode of the SimpleButton. |
void |
setBackground(java.awt.Color newColor)
Sets the background color. |
void |
setBackgroundStart(java.awt.Color newColor)
Sets the backgroundStart color. |
void |
setBorder(javax.swing.border.Border newBorder)
|
void |
setFireRate(int newRate)
Sets the rate of event firing in the CHAIN_MODE |
void |
setForeground(java.awt.Color newColor)
|
protected void |
setPressed(boolean newPressed)
Returns the property specifiing whether the button is being pressed. |
void |
setPressedBackground(java.awt.Color newColor)
Sets the background color displayed when the button is pressed. |
void |
setPressedBackgroundStart(java.awt.Color newColor)
Sets the starting background gradient color displayed when the button is pressed. |
void |
setPressedBorder(javax.swing.border.Border newBorder)
Sets the border displayed when the button is pressed. |
void |
setPressedForeground(java.awt.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(java.awt.Color newColor)
Sets the background color displayed when the mouse cursor is over the button and rollover is enabled. |
void |
setRolloverBackgroundStart(java.awt.Color newColor)
Sets the start of background gradient color displayed when the mouse cursor is over the button and rollover is enabled. |
void |
setRolloverBorder(javax.swing.border.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(java.awt.Color newColor)
Sets the foreground color displayed when the mouse cursor is over the button and rollover is enabled. |
void |
setVisible(boolean visible)
|
Methods inherited from class com.cosylab.gui.components.GradientLabel |
---|
isGradientEnabled, setGradientEnabled, setGradientPoints |
Methods inherited from class com.cosylab.gui.components.ResizableTextLabel |
---|
adjustSizeToFont, getColumns, getMaximumFontSize, getMinimumFontSize, getMinimumSize, getPreferredSize, isEnhanced, isResizable, resize, setColumns, setEnhanced, setMaximumFontSize, setMinimumFontSize, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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 |
Field Detail |
---|
protected static final java.lang.String MOUSE_PRESSED
protected static final java.lang.String MOUSE_CLICKED
protected static final java.lang.String MOUSE_RELEASED
protected static final java.lang.String MOUSE_CHAIN
public static final int NULL_ACTION_MODE
public static final int DEFAULT_ACTION_MODE
public static final int CHAIN_ACTION_MODE
public static final int FAST_ACTION_MODE
Constructor Detail |
---|
public SimpleButton(java.lang.String text)
text
- java.lang.String to be displayed on the button.public SimpleButton(javax.swing.Icon icon)
icon
- javax.swing.Icon to be displayed on the button.public SimpleButton()
Method Detail |
---|
public void setActionMode(int newMode)
fireRate
. 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.
newMode
- to be set.
java.lang.IllegalArgumentException
- if the value entered is not one of
DEFAULT_ACTION_MODE, CHAIN_ACTION_MODE, FAST_ACTION_MODE or
NULL_ACTION_MODE.public int getActionMode()
public void setBackground(java.awt.Color newColor)
GradientLabel
setBackground
in class GradientLabel
newColor
- The color to be setComponent.setBackground(Color)
,
GradientLabel.setBackgroundStart(Color)
public java.awt.Color getBackground()
getBackground
in class java.awt.Component
public void setForeground(java.awt.Color newColor)
setForeground
in class javax.swing.JComponent
public java.awt.Color getForeground()
getForeground
in class java.awt.Component
public java.awt.Color getBackgroundStart()
GradientLabel
getBackgroundStart
in class GradientLabel
public void setBackgroundStart(java.awt.Color newColor)
GradientLabel
setBackgroundStart
in class GradientLabel
newColor
- The backgroundStart to setGradientLabel.getBackgroundStart()
public void setBorder(javax.swing.border.Border newBorder)
setBorder
in class javax.swing.JComponent
public javax.swing.border.Border getBorder()
getBorder
in class javax.swing.JComponent
public java.awt.Color getPressedBackground()
public void setPressedBackground(java.awt.Color newColor)
newColor
- Colorpublic java.awt.Color getPressedForeground()
public void setPressedForeground(java.awt.Color newColor)
newColor
- Colorpublic java.awt.Color getPressedBackgroundStart()
public void setPressedBackgroundStart(java.awt.Color newColor)
newColor
- Colorpublic javax.swing.border.Border getPressedBorder()
public void setPressedBorder(javax.swing.border.Border newBorder)
newBorder
- Borderpublic java.awt.Color getRolloverBackground()
public void setRolloverBackground(java.awt.Color newColor)
newColor
- Colorpublic java.awt.Color getRolloverForeground()
public void setRolloverForeground(java.awt.Color newColor)
newColor
- Colorpublic java.awt.Color getRolloverBackgroundStart()
public void setRolloverBackgroundStart(java.awt.Color newColor)
newColor
- Colorpublic javax.swing.border.Border getRolloverBorder()
public void setRolloverBorder(javax.swing.border.Border newBorder)
newBorder
- Borderpublic void setRolloverEnabled(boolean enabled)
enabled
- boolean whether this SimpleButton should indicate when
mouse is over it.public boolean isRolloverEnabled()
public void setFireRate(int newRate)
newRate
- int time in miliseconds between successive events are
fired.public int getFireRate()
public boolean isPressed()
protected void setPressed(boolean newPressed)
newPressed
- booleanpublic boolean isRollover()
protected void setRollover(boolean newRollover)
newRollover
- booleanprotected void fireActionPerformed(java.awt.event.ActionEvent e)
e
- ActionEventpublic void addActionListener(java.awt.event.ActionListener l)
l
- ActionListenerpublic void removeActionListener(java.awt.event.ActionListener l)
l
- ActionListenerpublic void paintComponent(java.awt.Graphics g)
paintComponent
in class GradientLabel
g
- GraphicsGradientLabel.paintComponent(Graphics)
protected void paintBorder(java.awt.Graphics g)
paintBorder
in class javax.swing.JComponent
g
- GraphicsJComponent.paintBorder(Graphics)
public void addNotify()
ResizableTextLabel
addNotify
in class ResizableTextLabel
JComponent.addNotify()
public void removeNotify()
removeNotify
in class javax.swing.JComponent
public void setVisible(boolean visible)
setVisible
in class javax.swing.JComponent
public static void main(java.lang.String[] args)
args
- command line parameters
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |