public abstract class Button<O extends OutputManager<?>> extends AbstractButton<O,ButtonConfig> implements LabeledWidget<O>, MnemonicTrait<O>
Widget.ZOrderClass
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
command
Command to generate.
|
private Label<O> |
label
Label instance associated with widget.
|
private java.util.ArrayList<ActionListener> |
listeners
Container for listeners.
|
private MnemonicInfo |
mnemonic
Mnemonic information
|
config, widgetFocused
insets, location, LOG, mousePtr, nativeInsets, physicalLocation
Constructor and Description |
---|
Button(WidgetId id,
ButtonConfig cfg)
Special constructor used to restore component using given configuration.
|
Button(WidgetId id,
Container<O> owner,
java.lang.String text)
This constructor creates a button with a given text label.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(ActionListener listener)
Add action listener.
|
void |
afterConfigUpdate(ButtonConfig beforeUpdate)
The method is called after the configuration associated with
the implementor changes.
|
boolean |
checkKey(KeyInput keyEvent)
Check if passes key does match underscored character in the text.
|
ButtonConfig |
config()
Provide access to the attributes stored in the widget.
|
void |
destroy()
Destroy this widget.
|
double |
getColon()
Return current value of COLON option.
|
java.lang.String |
getColumnLabelText()
Return text of the column label.
|
java.lang.String |
getCommand()
Get command associated with button.
|
Label<O> |
getLabelInstance()
Return reference to the instance of the
Label attached to
the widget. |
java.lang.String |
getLabelText()
Return text of the label.
|
MnemonicInfo |
getMnemonic()
MnemonicInfo instance getter.
|
double |
getTo()
Return TO column.
|
protected void |
handleBasicEvents(KeyInput event)
Process basic events - TAB, BACK-TAB and ENTER key event.
|
private boolean |
handleHotkeys(KeyInput ki)
Handle space and keys that match the highlighted char in button text.
|
double |
height()
Calculate the height of this widget.
|
protected void |
initButtonText(java.lang.String text)
Initialize button text.
|
void |
initialize(WidgetId id,
ButtonConfig cfg)
Replacement API for the logic which should exist in the widget's c'tor, but the logic
can't be executed as it depends on the widget being registered into the official registry.
|
boolean |
isForceLabel()
Get current state of flag which is forces presence of the label
regardless from the frame NO-LABELS option.
|
boolean |
isMnemonicSupported()
Check whether this button supports mnemonics.
|
boolean |
isNoLabels()
Get current state of NO-LABELS flag.
|
boolean |
isRightAligned()
Get widget alignment policy.
|
void |
postprocessConfig()
Additional processing required when widget configuration is updated AFTER the frame layout
has been performed.
|
void |
processEvent(Event event)
Process event and dispatch it to specific method.
|
void |
processKeyEvent(KeyInput keyEvent)
Processes key events occurring on this object by dispatching them
to any registered KeyListener objects.
|
void |
requestFocus()
Request focus.
|
void |
setCommand(java.lang.String command)
Set command associated with button.
|
void |
setHidden(boolean hidden)
Tracks the hidden state of the widget and attached label.
|
void |
setLabelInstance(Label<O> label)
Assign new instance of
Label to the widget. |
void |
setMnemonic(MnemonicInfo mnemonic)
MnemonicInfo instance setter.
|
void |
setNoLabels(boolean labels)
Force NO-LABELS flag.
|
void |
setSupportsMnemonic()
Set the mnemonics support for this button.
|
void |
setText(java.lang.String text)
Set the new text for the component.
|
void |
setTextLabel(java.lang.String label)
Set button label.
|
void |
setVisible(boolean visible)
Shows or hides the button and its label.
|
void |
setWasVisible()
Remember the widget was made visible at least once.
|
java.lang.String |
textLabel()
Get label text.
|
boolean |
wasVisible()
Checking if the widget was made visible at least once.
|
double |
width()
Calculate the width of this widget.
|
dimension, 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, createMouseHoverAction, deactivateDirectManipulation, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, findMouseSource, focusTraversable, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCustomMousePointer, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getPortableMouseEventCoordinates, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidthNative, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, insets, isDirectManipulationCapable, isDirectManipulationRequired, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, mouseActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, prepParentLocation, processDirectManipulationEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, sync, topLevelWindow, toString, translate, unrealize, updateSizeWorker, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, defaultMousePtr, dimension, displayPhysicalLocation, draw, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, hidden, hide, highlighted, insets, isDirectManipulable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, location, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentOrSelf, physicalBounds, physicalDimension, physicalLocation, processDirectManipulationEvent, processFocusEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, repaint, requestSync, resizeTo, screen, screenLocation, screenPhysicalLocation, setEnabled, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, supportsCustomMousePointer, topLevelWindow, unrealize, window
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
createMnemonic, getColumnMnemonic, getMnemonicCharacter, getMnemonicKeyCode, getMnemonicLabel, setColumnMnemonic, updateMnemonic
private java.lang.String command
private java.util.ArrayList<ActionListener> listeners
private Label<O extends OutputManager<?>> label
private MnemonicInfo mnemonic
public Button(WidgetId id, Container<O> 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 Button(WidgetId id, ButtonConfig cfg)
Call 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 void initialize(WidgetId id, ButtonConfig cfg)
This API is called after the widget is created and added to the registry.
initialize
in interface WidgetWithConfig<ButtonConfig>
id
- The widget's ID.cfg
- The config used to initialize this widget.protected void initButtonText(java.lang.String text)
text
- Button text.public void addListener(ActionListener listener)
listener
- Listener to add.public boolean checkKey(KeyInput keyEvent)
keyEvent
- Event to check.true
if match is found.public ButtonConfig config()
config
in interface Widget<O extends OutputManager<?>>
config
in interface ConfigOwner<ButtonConfig>
config
in class AbstractButton<O extends OutputManager<?>,ButtonConfig>
public double getColon()
getColon
in interface LabeledWidget<O extends OutputManager<?>>
public java.lang.String getColumnLabelText()
getColumnLabelText
in interface LabeledWidget<O extends OutputManager<?>>
public Label<O> getLabelInstance()
Label
attached to
the widget.getLabelInstance
in interface LabeledWidget<O extends OutputManager<?>>
Label
instance.public java.lang.String getLabelText()
getLabelText
in interface LabeledWidget<O extends OutputManager<?>>
public double getTo()
getTo
in interface LabeledWidget<O extends OutputManager<?>>
public double height()
height
in interface Widget<O extends OutputManager<?>>
height
in class AbstractWidget<O extends OutputManager<?>>
public boolean isForceLabel()
isForceLabel
in interface LabeledWidget<O extends OutputManager<?>>
public boolean isNoLabels()
isNoLabels
in interface LabeledWidget<O extends OutputManager<?>>
public boolean isRightAligned()
isRightAligned
in interface LabeledWidget<O extends OutputManager<?>>
true
if widget is formatted for right alignment.public void processEvent(Event event)
processEvent
in interface Widget<O extends OutputManager<?>>
processEvent
in class AbstractWidget<O extends OutputManager<?>>
event
- Event to process.public void processKeyEvent(KeyInput keyEvent)
processKeyEvent
in interface Widget<O extends OutputManager<?>>
processKeyEvent
in class AbstractWidget<O extends OutputManager<?>>
keyEvent
- The event to be handled.private boolean handleHotkeys(KeyInput ki)
ki
- Input event.true
if key is handled.protected void handleBasicEvents(KeyInput event)
handleBasicEvents
in class AbstractButton<O extends OutputManager<?>,ButtonConfig>
event
- Key event to process.public void requestFocus()
requestFocus
in interface Widget<O extends OutputManager<?>>
requestFocus
in class AbstractWidget<O extends OutputManager<?>>
public java.lang.String getCommand()
public void setCommand(java.lang.String command)
command
- Command text.public void setLabelInstance(Label<O> label)
Label
to the widget.setLabelInstance
in interface LabeledWidget<O extends OutputManager<?>>
label
- Reference to new Label
instance.public void setNoLabels(boolean labels)
setNoLabels
in interface LabeledWidget<O extends OutputManager<?>>
labels
- New value of the flag.public void setText(java.lang.String text)
setText
in class AbstractButton<O extends OutputManager<?>,ButtonConfig>
text
- New text value.public void setTextLabel(java.lang.String label)
setTextLabel
in class AbstractButton<O extends OutputManager<?>,ButtonConfig>
label
- Label text.public java.lang.String textLabel()
textLabel
in class AbstractButton<O extends OutputManager<?>,ButtonConfig>
public void setVisible(boolean visible)
setVisible
in interface Widget<O extends OutputManager<?>>
setVisible
in class AbstractWidget<O extends OutputManager<?>>
visible
- true
to make the widget visible,
false
to hide the widget.public void setHidden(boolean hidden)
setHidden
in interface Widget<O extends OutputManager<?>>
setHidden
in class AbstractWidget<O extends OutputManager<?>>
hidden
- New hidden state.public double width()
width
in interface Widget<O extends OutputManager<?>>
width
in class AbstractWidget<O extends OutputManager<?>>
public boolean wasVisible()
wasVisible
in interface LabeledWidget<O extends OutputManager<?>>
true
if the widget was visible,
false
otherwise.public void setWasVisible()
setWasVisible
in interface LabeledWidget<O extends OutputManager<?>>
public void afterConfigUpdate(ButtonConfig beforeUpdate)
afterConfigUpdate
in interface ConfigOwner<ButtonConfig>
afterConfigUpdate
in class AbstractButton<O extends OutputManager<?>,ButtonConfig>
beforeUpdate
- public void postprocessConfig()
postprocessConfig
in interface Widget<O extends OutputManager<?>>
postprocessConfig
in class AbstractWidget<O extends OutputManager<?>>
public void destroy()
destroy
in interface Widget<O extends OutputManager<?>>
destroy
in class AbstractWidget<O extends OutputManager<?>>
public void setSupportsMnemonic()
public boolean isMnemonicSupported()
isMnemonicSupported
in interface MnemonicTrait<O extends OutputManager<?>>
true
if this button supports mnemonic.public MnemonicInfo getMnemonic()
The implementors should simply return the value of the mnemonic class field. No additional processing logic is advised.
getMnemonic
in interface MnemonicTrait<O extends OutputManager<?>>
public void setMnemonic(MnemonicInfo mnemonic)
The implementors should simply assign the parameter value to the mnemonic class field. No additional processing logic is advised.
setMnemonic
in interface MnemonicTrait<O extends OutputManager<?>>