Package org.jjazz.flatcomponents.api
Class FlatToggleButton
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
org.jjazz.flatcomponents.api.FlatButton
org.jjazz.flatcomponents.api.FlatToggleButton
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
,SwingConstants
A flat toggle button.
Selected button can use a specific foreground and icon.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
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
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
ConstructorDescriptionEquivalent of FlatToggleButton(true, true, false)FlatToggleButton
(boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag) Equivalent of FlatToggleButton(null, enablePressedBorder, enableEnteredBorder, enableDrag)Create a toggle button initialized with the specified ToggleAction.FlatToggleButton
(ToggleAction ta, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag) Create a toggle button initialized with the specified ToggleAction.FlatToggleButton
(org.openide.util.actions.BooleanStateAction bsa) Deprecated.FlatToggleButton
(org.openide.util.actions.BooleanStateAction bsa, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
doClick()
Simulate a user click.boolean
void
Overridden to add the support of the LARGE_ICON_KEY and BooleanState property.void
setBooleanStateAction
(org.openide.util.actions.BooleanStateAction bsa) Deprecated.void
Redirected to setUnselectedIcon(icon).void
setSelected
(boolean b) Change the selected status.void
void
setSelectedIcon
(Icon selectedIcon) void
Update button from a ToggleAction.void
setUnselectedIcon
(Icon icon) Methods inherited from class org.jjazz.flatcomponents.api.FlatButton
addActionListener, getAction, getBorderEntered, getBorderNothing, getBorderPressed, getToolTipText, removeActionListener, setAction, setBorderEntered, setBorderNothing, setBorderPressed
Methods inherited from class javax.swing.JLabel
getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, 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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, 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
-
Constructor Details
-
FlatToggleButton
public FlatToggleButton()Equivalent of FlatToggleButton(true, true, false) -
FlatToggleButton
public FlatToggleButton(boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag) Equivalent of FlatToggleButton(null, enablePressedBorder, enableEnteredBorder, enableDrag)- Parameters:
enablePressedBorder
-enableEnteredBorder
-enableDrag
-
-
FlatToggleButton
Deprecated.Equivalent of FlatToggleButton(bsa, true, true, false) -
FlatToggleButton
@Deprecated public FlatToggleButton(org.openide.util.actions.BooleanStateAction bsa, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag) Deprecated.Create a toggle button initialized with the specified action.- Parameters:
bsa
-enablePressedBorder
-enableEnteredBorder
-enableDrag
-
-
FlatToggleButton
Create a toggle button initialized with the specified ToggleAction.- Parameters:
ta
-
-
FlatToggleButton
public FlatToggleButton(ToggleAction ta, boolean enablePressedBorder, boolean enableEnteredBorder, boolean enableDrag) Create a toggle button initialized with the specified ToggleAction.- Parameters:
ta
-enablePressedBorder
-enableEnteredBorder
-enableDrag
-
-
-
Method Details
-
isSelected
public boolean isSelected() -
setSelected
public void setSelected(boolean b) Change the selected status.This does NOT fire a change event. Use doClick() to simulate a user click.
- Parameters:
b
-
-
doClick
public void doClick()Simulate a user click. -
setIcon
Redirected to setUnselectedIcon(icon). -
setBooleanStateAction
Deprecated.Set the button from a BooleanStateAction.When this togglebutton is clicked it just calls action.actionPerformed(). Button selected state will follow the BooleanStateAction.PROP_BOOLEAN_STATE action's property changes.
Reuse the following properties:
- "LARGE_ICON_KEY" property => setSelectedIcon()
- BooleanStateAction.PROP_BOOLEAN_STATE => setSelected()- Parameters:
bsa
- A non-null BooleanStateAction.
-
setToggleAction
Update button from a ToggleAction.When this togglebutton is clicked it just calls action.actionPerformed(). Button selected state will follow the Action.SELECTED_KEY action's property changes.
- Parameters:
ta
-
-
setUnselectedIcon
-
getUnselectedIcon
-
setSelectedIcon
-
getSelectedIcon
-
setSelectedForeground
-
getSelectedForeground
-
propertyChange
Overridden to add the support of the LARGE_ICON_KEY and BooleanState property.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Overrides:
propertyChange
in classFlatButton
- Parameters:
evt
-
-