Package jmri.jmrit.throttle
Class FunctionButton
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JToggleButton
jmri.jmrit.throttle.FunctionButton
- All Implemented Interfaces:
ImageObserver,ItemSelectable,MenuContainer,Serializable,Accessible,SwingConstants
A JButton to activate functions on the decoder. FunctionButtons have a
right-click popupMenu menu with several configuration options:
- Set the text
- Set the locking state
- Set visibility
- Set Font
- Set function number identity
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JToggleButton
JToggleButton.AccessibleJToggleButton, JToggleButton.ToggleButtonModelNested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListenerNested 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
FieldsFields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTYFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a listener to this button, probably some sort of keypad panel.voiddestroy()static intGet Button Height.intGet the Image Button Width.Get the Button Label.static intGet the Button Width.booleanGet the display state of the button.Get the Icon Path, NON selected.intGet the function number this button operates.booleanGet the locking state of the function.Get the Selected Icon Path.booleangetState()Get the state of the function.protected ThrottleGet Throttle for this button.org.jdom2.ElementgetXml()Collect the prefs of this object into XML Element.booleanisDirty()Get if Button is Dirty.booleanGet if isImageOK.booleanGet if isSelectedImageOK.voidRemove a listener from this button.voidsetButtonImageSize(int is) Set the Image Button Hieght and Width.voidsetButtonLabel(String label) Set the Button Label.voidsetDirty(boolean dirty) Set Function Button Dirty.voidsetDisplay(boolean displayed) Set the display state of the button.(package private) voidsetDropFolder(String df) Set the folder where droped images in function button property panel will be storedvoidsetIconPath(String fnImg) Set the Icon Path, NON selected.voidsetIdentity(int id) Set the function number this button will operate.voidsetIsLockable(boolean isLockable) Set the locking state of the button.voidsetSelected(boolean newState) Change the state of the function.voidsetSelectedIconPath(String fnImg) Set the Selected Icon Path.voidsetState(boolean isOn) Set the state of the function button.voidSet Button Text.protected voidsetThrottle(Throttle throttle) Set Throttle.voidsetXml(org.jdom2.Element e) Set the preferences based on the XML Element.voidUpdate Button Look and Feel !Methods inherited from class javax.swing.JToggleButton
getAccessibleContext, getUIClassID, paramString, requestFocus, requestFocusInWindow, updateUIMethods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelectedIcon, setUI, setVerticalAlignment, setVerticalTextPositionMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, 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, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, 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
-
DEFAULT_IMG_SIZE
- See Also:
-
-
Constructor Details
-
FunctionButton
public FunctionButton()Construct the FunctionButton.
-
-
Method Details
-
destroy
-
getButtonHeight
Get Button Height.- Returns:
- height.
-
getButtonWidth
Get the Button Width.- Returns:
- width.
-
getButtonImageSize
Get the Image Button Width.- Returns:
- width.
-
setButtonImageSize
Set the Image Button Hieght and Width.- Parameters:
is- the image size (sqaure image size = width = height)
-
setIdentity
Set the function number this button will operate.- Parameters:
id- An integer, minimum 0.
-
getIdentity
Get the function number this button operates.- Returns:
- An integer, minimum 0.
-
setState
Set the state of the function button. Does not send update to layout, just updates button status.To update AND send to layout use setSelected(boolean).
- Parameters:
isOn- True if the function should be active.
-
getState
Get the state of the function.- Returns:
- true if the function is active.
-
setIsLockable
Set the locking state of the button.Changes in this parameter are only be sent to the listeners if the dirty bit is set.
- Parameters:
isLockable- True if the a clicking and releasing the button changes the function state. False if the state is changed back when the button is released
-
getIsLockable
Get the locking state of the function.- Returns:
- True if the a clicking and releasing the button changes the function state. False if the state is changed back when button is released
-
setDisplay
Set the display state of the button.- Parameters:
displayed- True if the button exists False if the button has been removed by the user
-
getDisplay
Get the display state of the button.- Returns:
- True if the button exists False if the button has been removed by the user
-
setDirty
Set Function Button Dirty.- Parameters:
dirty- True when button has been modified by user, else false.
-
isDirty
Get if Button is Dirty.- Returns:
- true when function button has been modified by user.
-
getButtonLabel
Get the Button Label.- Returns:
- Button Label text.
-
setButtonLabel
Set the Button Label.- Parameters:
label- Label Text.
-
setText
Set Button Text.- Overrides:
setTextin classAbstractButton
-
updateLnF
Update Button Look and Feel ! Hide/show it if necessary Decide if it should show the label or an image with text as tooltip. Button UI updated according to above result. -
setSelected
Change the state of the function. Sets internal state, setSelected, and sends to listeners.To update this button WITHOUT sending to layout, use setState.
- Overrides:
setSelectedin classAbstractButton- Parameters:
newState- true = Is Function on, False = Is Function off.
-
addFunctionListener
Add a listener to this button, probably some sort of keypad panel.- Parameters:
l- The FunctionListener that wants notifications via the FunctionListener.notifyFunctionStateChanged.
-
removeFunctionListener
Remove a listener from this button.- Parameters:
l- The FunctionListener to be removed
-
setDropFolder
Set the folder where droped images in function button property panel will be stored- Parameters:
df- the folder path
-
getXml
Collect the prefs of this object into XML Element.- identity
- text
- isLockable
- Returns:
- the XML of this object.
-
setXml
Set the preferences based on the XML Element.- identity
- text
- isLockable
- Parameters:
e- The Element for this object.
-
setIconPath
Set the Icon Path, NON selected.Checks image and sets isImageOK flag.
- Parameters:
fnImg- icon path.
-
getIconPath
Get the Icon Path, NON selected.- Returns:
- Icon Path, else empty string if null.
-
setSelectedIconPath
Set the Selected Icon Path.Checks image and sets isSelectedImageOK flag.
- Parameters:
fnImg- selected icon path.
-
getSelectedIconPath
Get the Selected Icon Path.- Returns:
- selected Icon Path, else empty string if null.
-
isImageOK
Get if isImageOK.- Returns:
- true if isImageOK.
-
isSelectedImageOK
Get if isSelectedImageOK.- Returns:
- true if isSelectedImageOK.
-
setThrottle
Set Throttle.- Parameters:
throttle- the throttle that this button is associated with.
-
getThrottle
Get Throttle for this button.- Returns:
- throttle associated with this button. May be null if no throttle currently associated.
-