Package-level declarations

Types

Link copied to clipboard

A mutable view of a text document handed to DocumentState.edit. Calls made on it inside the edit { } block are applied to the document as one compound change, so the field observes a single settled edit rather than each intermediate step.

Link copied to clipboard
@Stable
class DocumentState : RememberObserver

A hoistable state holder for a text component that owns the Document the component renders. The state and the bound component share one document, so an edit made through this state is what the component displays, and text the user types into the component is what this state reports - there is no value to keep in sync and no round-trip per keystroke. A caller who needs a document of their own supplies it at rememberDocumentState; content is otherwise read through text and changed through edit.

Link copied to clipboard
@Stable
class FormattedValueState

A hoistable state holder for a FormattedTextField: the value the field holds, whether the characters it currently shows parse, and the gesture that takes a typed edit on demand.

Functions

Link copied to clipboard
@Composable
fun EditorPane(state: DocumentState, modifier: SwingModifier = SwingModifier, editable: Boolean = true)

An EditorPane driven by a DocumentState. The pane renders the state's own document, so text typed into the pane and edits made through the state are the same content, and the caret is kept two-way with DocumentState.selection. The state is the single source of truth; there is no onValueChange.

@Composable
fun EditorPane(markup: @Nls String, hyperlinkListener: HyperlinkListener, modifier: SwingModifier = SwingModifier, contentType: String = "text/plain", baseUrl: URL? = null)

An EditorPane driven by a raw HyperlinkListener instead of an onLinkActivate lambda. The listener hears every link event the pane publishes - entered and left as well as activated - and reaches the resolved URL and the source element behind each; pass a stable instance (e.g. remember {}) to avoid churn.

@Composable
fun EditorPane(markup: @Nls String, onLinkActivate: (String) -> Unit, modifier: SwingModifier = SwingModifier, contentType: String = "text/plain", baseUrl: URL? = null)

Rendered markup: markup is source written in the language contentType names, and the JEditorPane shows what the kit registered for that content type makes of it, so EditorPane("<h1>Report</h1>", { href -> open(href) }, contentType = "text/html") renders a heading rather than the characters that spell one.

Link copied to clipboard
@Composable
fun FormattedTextField(state: FormattedValueState, modifier: SwingModifier = SwingModifier, formatterFactory: JFormattedTextField.AbstractFormatterFactory? = null, focusLostBehavior: Int = JFormattedTextField.COMMIT_OR_REVERT, columns: Int = 0, editable: Boolean = true)

A FormattedTextField driven by a FormattedValueState. The field renders the state's value and commits into it, and reports through the state whether the characters it currently shows parse. The state is the single source of truth; there is no onValueChange and no onEditValidChange.

@Composable
fun FormattedTextField(value: Any?, valuePropertyChangeListener: PropertyChangeListener, modifier: SwingModifier = SwingModifier, formatterFactory: JFormattedTextField.AbstractFormatterFactory? = null, onEditValidChange: (Boolean) -> Unit = {}, focusLostBehavior: Int = JFormattedTextField.COMMIT_OR_REVERT, columns: Int = 0, editable: Boolean = true)

A FormattedTextField driven by a raw PropertyChangeListener (bound to the value property) instead of an onValueChange lambda. The listener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. Being attached as-is, it is notified of every change to the value property, including the one that applies value.

@Composable
fun FormattedTextField(value: Any?, onValueChange: (Any?) -> Unit, modifier: SwingModifier = SwingModifier, formatterFactory: JFormattedTextField.AbstractFormatterFactory? = null, onEditValidChange: (Boolean) -> Unit = {}, focusLostBehavior: Int = JFormattedTextField.COMMIT_OR_REVERT, columns: Int = 0, editable: Boolean = true)

A single line of text standing for a typed value: a number, a date, or input matching a fixed mask. The JFormattedTextField renders the value as formatted text and parses what the user types back into a value of that type.

Link copied to clipboard
@Composable
fun PasswordField(state: DocumentState, modifier: SwingModifier = SwingModifier, echoChar: Char? = null, columns: Int = 0, editable: Boolean = true)

A PasswordField driven by a DocumentState. The field renders the state's own document, so masked text typed into the field and edits made through the state are the same content, and the caret is kept two-way with DocumentState.selection. The state is the single source of truth.

@Composable
fun PasswordField(value: CharArray, documentListener: DocumentListener, modifier: SwingModifier = SwingModifier, echoChar: Char? = null, columns: Int = 0, editable: Boolean = true)

A PasswordField driven by a raw DocumentListener instead of an onValueChange lambda. The documentListener is attached to the field's document as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. Being attached as-is, it observes every change to that document, including the one that applies value.

@Composable
fun PasswordField(value: CharArray, onValueChange: (CharArray) -> Unit, modifier: SwingModifier = SwingModifier, echoChar: Char? = null, columns: Int = 0, editable: Boolean = true)

A single line of editable text the JPasswordField shows as masking characters rather than as what was typed. It holds the characters value declares and reports every edit as the field's whole contents.

Link copied to clipboard
@Composable
fun rememberDocumentState(document: Document, kit: EditorKit? = null): DocumentState

Creates and remembers a DocumentState over an existing document, leaving its current content in place. The bound field renders this exact document, so a caller keeping a reference to it observes the same edits the state does.

@Composable
fun rememberDocumentState(kit: EditorKit, initialText: @Nls CharSequence = ""): DocumentState

Creates and remembers a DocumentState over a fresh document built by kit and seeded by reading initialText through it. Reach for this over the contentType form when the kit is configured - a style sheet of your own, a custom parser, a kit class the registry does not name.

@Composable
fun rememberDocumentState(initialText: @Nls CharSequence = "", contentType: String = "text/plain"): DocumentState

Creates and remembers a DocumentState over a fresh document in the language contentType names, seeded with initialText.

Link copied to clipboard
@Composable
fun rememberFormattedValueState(initialValue: Any? = null): FormattedValueState

Creates and remembers a FormattedValueState holding initialValue.

Link copied to clipboard
@Composable
fun TextArea(state: DocumentState, modifier: SwingModifier = SwingModifier, rows: Int = 0, columns: Int = 0, editable: Boolean = true, lineWrap: Boolean = false, wrapStyleWord: Boolean = false, tabSize: Int = DEFAULT_TAB_SIZE)

A TextArea driven by a DocumentState. The area renders the state's own document, so text typed into the area and edits made through the state are the same content, and the caret is kept two-way with DocumentState.selection. The state is the single source of truth; there is no onValueChange.

@Composable
fun TextArea(value: @Nls String, documentListener: DocumentListener, modifier: SwingModifier = SwingModifier, rows: Int = 0, columns: Int = 0, editable: Boolean = true, lineWrap: Boolean = false, wrapStyleWord: Boolean = false, tabSize: Int = DEFAULT_TAB_SIZE)

A TextArea driven by a raw DocumentListener instead of an onValueChange lambda. The documentListener is attached to the area's document as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. Being attached as-is, it observes every change to that document, including the one that applies value.

@Composable
fun TextArea(value: @Nls String, onValueChange: (@Nls String) -> Unit, modifier: SwingModifier = SwingModifier, rows: Int = 0, columns: Int = 0, editable: Boolean = true, lineWrap: Boolean = false, wrapStyleWord: Boolean = false, tabSize: Int = DEFAULT_TAB_SIZE)

Multiple lines of editable plain text. The JTextArea shows the text value declares, and every edit reports the area's whole text through onValueChange.

Link copied to clipboard
@Composable
fun TextField(state: DocumentState, modifier: SwingModifier = SwingModifier, columns: Int = 0, editable: Boolean = true)

A TextField driven by a DocumentState. The field renders the state's own document, so text typed into the field and edits made through the state are the same content, and the caret is kept two-way with DocumentState.selection. The state is the single source of truth; there is no onValueChange.

@Composable
fun TextField(value: @Nls String, documentListener: DocumentListener, modifier: SwingModifier = SwingModifier, columns: Int = 0, editable: Boolean = true)

A TextField driven by a raw DocumentListener instead of an onValueChange lambda. The documentListener is attached to the field's document as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. It observes every change to that document, including the one that applies value.

@Composable
fun TextField(value: @Nls String, onValueChange: (@Nls String) -> Unit, modifier: SwingModifier = SwingModifier, columns: Int = 0, editable: Boolean = true)

A single line of editable plain text. The JTextField shows the text value declares, and every edit reports the field's whole text through onValueChange.

Link copied to clipboard
@Composable
fun TextPane(state: DocumentState, modifier: SwingModifier = SwingModifier, editable: Boolean = true)

A TextPane driven by a DocumentState. The pane renders the state's own document, so text typed into the pane and edits made through the state are the same content, and the caret is kept two-way with DocumentState.selection. The state is the single source of truth; there is no onValueChange.

@Composable
fun TextPane(value: @Nls String, documentListener: DocumentListener, modifier: SwingModifier = SwingModifier, editable: Boolean = true)

A TextPane driven by a raw DocumentListener instead of an onValueChange lambda. The listener observes the document the pane currently holds and follows it across a document swap; pass a stable instance (e.g. remember {}) to avoid churn. Being attached as-is, it observes every change to that document, including the one that applies value.

@Composable
fun TextPane(value: @Nls String, onValueChange: (@Nls String) -> Unit, modifier: SwingModifier = SwingModifier, editable: Boolean = true)

Editable text carrying graphical attributes - fonts, colors, embedded icons and components - over the styled document a JTextPane holds.