Package-level declarations

Types

Link copied to clipboard
@Stable
class FocusRequester

A hoistable handle that moves keyboard focus to the component it is bound to with focusRequester, so an application event - a validation failure, a toolbar action, a shortcut - can decide what the keyboard drives.

Functions

Link copied to clipboard

Sets the command string a button puts on the ActionEvent it fires, read back as event.actionCommand. It is what tells two buttons apart inside one shared listener, and it stays put when the button's text changes with the locale. null restores the default, where a button reports its own text as the command.

Link copied to clipboard

Enrolls this button in group, so at most one of the buttons declared with it is selected. Requires an AbstractButton target (a radio button, a toggle button, a checkbox, or a button menu item).

Link copied to clipboard

Installs caret as the text component's caret - the object that holds the insertion point and the selection, paints them, and answers the focus and mouse gestures that move them. Removing the declaration puts back the caret the component carried before.

Link copied to clipboard

How fast the component's caret blinks: the delay in milliseconds between the caret being shown and being hidden again. 0 holds it steady.

Link copied to clipboard

Sets what the caret does when the document is edited somewhere other than where the caret sits.

Link copied to clipboard

Makes this button the default button of the window it is in - the one the look and feel's activation keystroke, Enter in the look and feels the JDK ships, activates wherever the focus sits, as long as the button is an enabled descendant of the root pane at that moment. A component that consumes the activation event itself, a text pane among them, keeps it. The association follows the button when it moves to another window, and is released when default is false or the modifier leaves. Requires a JButton target.

Link copied to clipboard

Installs filter on the text component's document so it can inspect, reject, or rewrite every insert, remove, and replace before it is applied. A null filter clears any filter the modifier previously installed. Requires a JTextComponent target whose document is an AbstractDocument. A JFormattedTextField is rejected: its document filter belongs to its formatter, which returns it from JFormattedTextField.AbstractFormatter.getDocumentFilter and reinstalls it whenever the field reformats.

Link copied to clipboard

Sets isEnabled on this component only - whether it responds to user input and paints in its enabled state. Disabling a container does not disable the components inside it, so disable each child you want disabled.

Link copied to clipboard

Sets isFocusable, declaring whether this component can receive keyboard focus.

Link copied to clipboard

The key that moves the keyboard focus to this text component when pressed with the platform's accelerator modifier - Alt on Windows and Linux, Ctrl+Alt on macOS. It reaches the component from anywhere in the focused window, so a form's fields can be jumped to without tabbing through it.

Link copied to clipboard

Binds focusRequester to this component, so FocusRequester.requestFocus moves keyboard focus to it. The binding follows the modifier: it ends when the modifier leaves the chain or the component leaves the composition, and a different requester declared on a later recomposition takes the binding over from the previous one.

Link copied to clipboard

Assigns this component a position in its container's keyboard focus-traversal order. Lower indices are reached first when tabbing forward. Effective only inside a container that installs the composition-order policy via orderedFocusTraversal; components without an index follow the indexed ones in their natural order.

Link copied to clipboard

Declares that this component takes keyboard focus when its window first shows it - the field a form or a dialog opens on.

Link copied to clipboard

Gates keyboard focus leaving this component on verify: while it answers false, Swing keeps the focus where it is, whether the user tabs away, clicks another control, or the application requests the move.

Link copied to clipboard

Installs filter on the text component so it decides where the caret lands before every move: an arrow key, a click, and a selection assigned in code all pass through it, and each may be redirected to another offset or left where it is. A null filter leaves the caret free to go anywhere in the document.

Link copied to clipboard

Runs onAccept when this text field accepts its value - the field's own action event, the one its Enter binding fires - so a search box, a command entry or a login form acts on the keyboard.

Link copied to clipboard
fun SwingModifier.onFocus(onGained: () -> Unit = UNDECLARED_ACTION, onLost: () -> Unit = UNDECLARED_ACTION): SwingModifier

Installs focus gained/lost handlers.

Link copied to clipboard
fun SwingModifier.onHover(onEnter: () -> Unit = UNDECLARED_ACTION, onExit: () -> Unit = UNDECLARED_ACTION): SwingModifier

Installs mouse enter/exit handlers.

Link copied to clipboard
fun SwingModifier.onPointerEvent(onPress: (MouseEvent) -> Unit? = null, onRelease: (MouseEvent) -> Unit? = null, onClick: (MouseEvent) -> Unit? = null): SwingModifier

Installs mouse press/release/click handlers. onPress fires on MOUSE_PRESSED, onRelease on MOUSE_RELEASED, and onClick on a completed click; each receives the MouseEvent (button, click count, point, modifiers). This is the low-level complement to a widget's domain onClick: use it for arbitrary components (a Label, a FlowPanel) or for right/middle-button handling.

Link copied to clipboard

Makes this container a focus-cycle root whose Tab order follows its children's focusTraversalIndex values (ascending), rather than their on-screen geometry. Children without an index are visited after the indexed ones. Requires a JComponent target.

Link copied to clipboard

Creates and remembers a FocusRequester for the composition it is called in.

Link copied to clipboard

Whether the inputVerifier of the component that currently holds the keyboard is consulted before focus moves to this component. Swing's own value is true; declare false on a control that must act regardless of what the focused field holds, such as a Cancel button or a scrollbar.