public abstract class GuiButton extends Button<GuiOutputManager>
Button objects. Instances of this
class are notified when mouse hovers over them, and when they are pressed down using the mouse.
The implementation will track mouse events on this button and provide the current state using
getters. It also supports the any combination of pressed and hover, if pressed and mouse cursor
is dragged outside the bounds, the state is kept as pressed, so in an eventual re-enter event
the state is correct. It's up to called to caller renderer to draw the state of the button and
the listener to act on the state provided by this class.| Modifier and Type | Field and Description |
|---|---|
private boolean |
mouseDragging
The mouse is dragging
|
private boolean |
mouseOver
Whether the mouse is over this button.
|
private java.awt.Point |
pressedLoc
Pressed button state flag.
|
config, widgetFocusedinsets, location, LOG, mousePtr, nativeInsets, physicalLocation| Constructor and Description |
|---|
GuiButton(WidgetId id,
ButtonConfig cfg)
Special constructor used to restore component using given configuration.
|
GuiButton(WidgetId id,
Container<GuiOutputManager> owner,
java.lang.String text)
This constructor creates a button with a given text label.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isMouseOver()
Checks if the mouse hovers over this widget.
|
boolean |
isPressed()
Checks pressed mouse state on this widget.
|
protected int[] |
mouseActions()
Determine the mouse actions processed by this widget.
|
void |
mouseDragged(java.awt.event.MouseEvent e)
Notification of a mouse dragged event occurred for this widget.
|
void |
mouseEntered(java.awt.event.MouseEvent e)
Process the notification of a mouse enter event occurred for this widget.
|
void |
mouseExited(java.awt.event.MouseEvent e)
Process the notification of a mouse leave event occurred for this widget.
|
void |
mouseMoved(java.awt.event.MouseEvent e)
Notification of a mouse moved event occurred for this widget.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Notification of a mouse pressed event occurred for this widget.
|
void |
mouseReleased(java.awt.event.MouseEvent e)
Notification of a mouse released event occurred for this widget.
|
addListener, afterConfigUpdate, checkKey, config, destroy, getColon, getColumnLabelText, getCommand, getLabelInstance, getLabelText, getMnemonic, getTo, handleBasicEvents, height, initButtonText, initialize, isForceLabel, isMnemonicSupported, isNoLabels, isRightAligned, postprocessConfig, processEvent, processKeyEvent, requestFocus, setCommand, setHidden, setLabelInstance, setMnemonic, setNoLabels, setSupportsMnemonic, setText, setTextLabel, setVisible, setWasVisible, textLabel, wasVisible, widthdimension, draw, forceCursorOnFocus, getDefaultEvent, handleCursorKeys, ignoreAction, manageSystemActions, minimumSize, onFocusGained, onFocusLost, onKeyPressed, onKeyTyped, processKeyEventCommon, refresh, setActionCode_setHidden, _setVisible, activateDirectManipulation, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, copyState, createMouseHoverAction, deactivateDirectManipulation, debug, disable, disableTooltip, displayPhysicalLocation, drawCaret, enable, enableTooltip, enclosingFrame, findMouseSource, focusTraversable, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getCustomMousePointer, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hasTooltip, hidden, hide, highlighted, initialHeight, initialWidth, insets, isCurrent, isDirectManipulationActive, isDirectManipulationActiveOrInUIB, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isMouseDrag, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, mouseClicked, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, oleDoDrop, oleDrag, oleDragging, oleStartDragging, onOleDragging, onOleDropEnd, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processFocusEvent, processKeyEventForSelectableWidget, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, reflectAncestorChange, reflectLocationChanged, reflectSizeChanged, refresh, registerWidgetListener, repaint, repaint, repaint, requestFocus, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setDirectManipulationActive, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setMousePointer, setParent, setPhysicalDimensionInt, setPhysicalLocation, setSensitiveForUIB, setState, setWindow, show, showPopupMenu, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, triggerLocationChanged, unrealize, unregisterWidgetListener, updateSizeWorker, updateSystemParent, widgetRealized, widgetStateChanged, windowclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitacceptsEscAsAnyKey, acceptTrigger, addFocusListener, addKeyListener, ancestor, ancestorId, bounds, canMovetoTop, clearWidget, completeTrigger, defaultMousePtr, dimension, displayPhysicalLocation, draw, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getIdForTrigger, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getMousePosition, getSelectedText, getState, getTriggerWidget, getTriggerWidget, getVisiblePart, getZOrderClass, hasFocus, hasFocus, hasTooltip, hidden, hide, highlighted, ignoreEnable, initialHeight, initialWidth, insets, isCurrent, isCurrent, isDirectManipulable, isDirectManipulationActive, isDirectManipulationActiveOrInUIB, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isInitialValueLayout, isLegacyFocus, isProcessProgressEvent, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, minimumSize, moveToBottom, moveToTop, name, navigable, oleDrag, parent, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, preventFocusWhenMouseDownEventDefined, processDirectManipulationEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, refreshWidget, registerWidgetListener, repaint, repaint, repaint, requestFocus, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setDirectManipulationActive, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setMousePointer, setParent, setPhysicalLocation, setSensitiveForUIB, setState, setWindow, show, startTrigger, supportsCustomMousePointer, systemFocusGrabbed, topLevelWindow, unrealize, unregisterWidgetListener, validateDisplayValue, widgetStateChanged, windowcreateMnemonic, getColumnMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, setColumnMnemonic, updateMnemonicprivate boolean mouseOver
private java.awt.Point pressedLoc
private boolean mouseDragging
public GuiButton(WidgetId id, Container<GuiOutputManager> owner, java.lang.String text)
id - The widget's ID.owner - The parent container, frame or dialog which will include this
button.text - The string to be used as the button text.public GuiButton(WidgetId id, ButtonConfig cfg)
Call Button.initialize(com.goldencode.p2j.ui.WidgetId, com.goldencode.p2j.ui.ButtonConfig) to finish the widget initialization.
id - The widget's ID.cfg - Configuration data.public boolean isMouseOver()
true if the mouse pointer is inside the visible bounds of this widgetpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenermouseEntered in class AbstractWidget<GuiOutputManager>e - The mouse event.public void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenermouseExited in class AbstractWidget<GuiOutputManager>e - The mouse event.public boolean isPressed()
true if user pressed the left mouse button on this widget and has not
released it yet.public void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenermousePressed in class AbstractWidget<GuiOutputManager>e - The mouse event.public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenermouseMoved in class AbstractWidget<GuiOutputManager>e - The mouse event.public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenermouseDragged in class AbstractWidget<GuiOutputManager>e - The mouse event.public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenermouseReleased in class AbstractWidget<GuiOutputManager>e - The mouse event.protected int[] mouseActions()
mouseActions in class AbstractWidget<GuiOutputManager>