Package-level declarations

Types

Link copied to clipboard
sealed interface ListItemScope

The receiver of the composable cell body a ListCellRenderer stamps a row through: the three values the widget hands a ListCellRenderer for the row being stamped, exposed as read-only composition state so the cell can lay itself out by index, selection, and focus. A ListBox or ComboBox item cell is one such body, as is one a caller writes over their own JList or JComboBox with rememberListItemRenderer.

Link copied to clipboard
@Stable
class ListState @RememberInComposition constructor(initialSelectedIndices: Set<Int> = emptySet())

A hoistable state holder for the selection of a ListBox, carrying the gesture that brings one of its rows into view.

Link copied to clipboard
sealed interface RadioGroupScope

Declarative choices of a RadioGroup. Each option call appends one radio button, in call order; its position is the index reported to RadioGroup's onSelectionChange and matched against selectedIndex.

Link copied to clipboard
sealed interface TableCellScope

The receiver a Table cell composes against: the inputs the table hands a TableCellRenderer for the cell being stamped, exposed as read-only composition state so the cell can lay itself out by row, column, selection and focus.

Link copied to clipboard
class TableColumnLayout(val modelIndices: List<Int>, val preferredWidths: List<Int>)

The layout of a Table's columns: which of the model's columns each view position shows, and how wide each of those positions wants to be.

Link copied to clipboard
sealed interface TableScope<R>

Declares the columns of a Table. Each column call appends one column, in call order.

Link copied to clipboard
@Stable
class TableState @RememberInComposition constructor(initialSelectedRowIndices: Set<Int> = emptySet())

A hoistable state holder for what a Table has selected, carrying the gesture that brings one of its rows into view.

Link copied to clipboard
sealed interface TreeNodeScope

The receiver a Tree node composes against: the row inputs the tree hands a TreeCellRenderer for the node being stamped, exposed as read-only composition state so the node can lay itself out by position, selection, expansion and focus.

Link copied to clipboard
@Stable
class TreeState @RememberInComposition constructor(initialSelectedPaths: Set<List<Int>> = emptySet(), initialExpandedPaths: Set<List<Int>> = emptySet())

A hoistable state holder for what a Tree has selected and what it has open, carrying the gesture that brings one of its nodes into view.

Functions

Link copied to clipboard
inline fun <R, V : Any> TableScope<R>.column(header: @Nls String, isEditable: Boolean = false, noinline isCellEditable: (row: R, rowIndex: Int) -> Boolean? = null, isSortable: Boolean = true, comparator: Comparator<Any?>? = null, minWidth: Int = COLUMN_MIN_WIDTH, maxWidth: Int = COLUMN_MAX_WIDTH, noinline onCellEdit: (row: R, rowIndex: Int, newValue: V?) -> Unit = { _, _, _ -> }, noinline cellContent: @Composable TableCellScope.(row: R) -> Unit? = null, noinline value: (row: R) -> V?)

Declares one column of V values, taking the column's class from the type value returns.

fun <R> TableScope<R>.column(header: @Nls String, columnClass: Class<*>, isEditable: Boolean = false, isCellEditable: (row: R, rowIndex: Int) -> Boolean? = null, isSortable: Boolean = true, comparator: Comparator<Any?>? = null, minWidth: Int = COLUMN_MIN_WIDTH, maxWidth: Int = COLUMN_MAX_WIDTH, onCellEdit: (row: R, rowIndex: Int, newValue: Any?) -> Unit = { _, _, _ -> }, cellContent: @Composable TableCellScope.(row: R) -> Unit? = null, value: (row: R) -> Any?)

Declares one column of columnClass values.

Link copied to clipboard
@Composable
fun <T> ListBox(model: ListModel<T>, state: ListState, modifier: SwingModifier = SwingModifier, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, visibleRowCount: Int = 8, layoutOrientation: Int = JList.VERTICAL, prototypeCellValue: T? = null, fixedCellWidth: Int = -1, fixedCellHeight: Int = -1, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A model-driven ListBox driven by a ListState instead of a declared selectedIndices and an onSelectionChange lambda. The state owns the selection: the rows it holds are what the list shows selected, the user's own selecting is written back into it, and it is where a row is revealed from.

@Composable
fun <T> ListBox(items: List<T>, state: ListState, modifier: SwingModifier = SwingModifier, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, visibleRowCount: Int = 8, layoutOrientation: Int = JList.VERTICAL, prototypeCellValue: T? = null, fixedCellWidth: Int = -1, fixedCellHeight: Int = -1, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A ListBox driven by a ListState instead of a declared selectedIndices and an onSelectionChange lambda. The state owns the selection: the rows it holds are what the list shows selected, the user's own selecting is written back into it, and it is where a row is revealed from.

@Composable
fun <T> ListBox(model: ListModel<T>, listSelectionListener: ListSelectionListener, modifier: SwingModifier = SwingModifier, selectedIndices: Set<Int>? = null, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, visibleRowCount: Int = 8, layoutOrientation: Int = JList.VERTICAL, prototypeCellValue: T? = null, fixedCellWidth: Int = -1, fixedCellHeight: Int = -1, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A model-driven ListBox driven by a raw ListSelectionListener instead of an onSelectionChange lambda. The listener sees the adjusting events of a drag as well as the settled one, and is notified of the user's selection changes only; the latest declared instance is the one notified, so the listener may be declared inline.

@Composable
fun <T> ListBox(model: ListModel<T>, modifier: SwingModifier = SwingModifier, selectedIndices: Set<Int>? = null, onSelectionChange: (Set<Int>) -> Unit = {}, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, visibleRowCount: Int = 8, layoutOrientation: Int = JList.VERTICAL, prototypeCellValue: T? = null, fixedCellWidth: Int = -1, fixedCellHeight: Int = -1, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A ListBox driven by a caller-owned ListModel instead of a declarative items list. The model is installed as-is and observed only: the library never mutates it, so element changes are the caller's responsibility. Selection is declared with selectedIndices and reported through onSelectionChange, and survives a model swap whether declared or not.

@Composable
fun <T> ListBox(items: List<T>, listSelectionListener: ListSelectionListener, modifier: SwingModifier = SwingModifier, selectedIndices: Set<Int>? = null, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, visibleRowCount: Int = 8, layoutOrientation: Int = JList.VERTICAL, prototypeCellValue: T? = null, fixedCellWidth: Int = -1, fixedCellHeight: Int = -1, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A ListBox driven by a raw ListSelectionListener instead of an onSelectionChange lambda. The listener sees the adjusting events of a drag as well as the settled one, and is notified of the user's selection changes only; the latest declared instance is the one notified, so the listener may be declared inline.

@Composable
fun <T> ListBox(items: List<T>, modifier: SwingModifier = SwingModifier, selectedIndices: Set<Int>? = null, onSelectionChange: (Set<Int>) -> Unit = {}, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, visibleRowCount: Int = 8, layoutOrientation: Int = JList.VERTICAL, prototypeCellValue: T? = null, fixedCellWidth: Int = -1, fixedCellHeight: Int = -1, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A column of rows the user picks from: a JList showing one row per item, reporting what the user selects.

Link copied to clipboard

Renders the items of the component this modifier applies to through renderer.

Link copied to clipboard
@Composable
fun RadioGroup(selectedIndex: Int, onSelectionChange: (Int) -> Unit, modifier: SwingModifier = SwingModifier, axis: Int = BoxLayout.Y_AXIS, content: RadioGroupScope.() -> Unit)

A set of mutually exclusive choices, backed by a shared ButtonGroup, so at most one option is selected at a time.

Link copied to clipboard
@Composable
inline fun <T : Any> rememberListItemRenderer(noinline content: @Composable ListItemScope.(item: T) -> Unit): ListCellRenderer<*>

Remembers the renderer that stamps content for every item of a component it is installed on, captured against the enclosing composition so the cell sees the state and androidx.compose.runtime.CompositionLocals around this call.

@Composable
fun <T : Any> rememberListItemRenderer(itemType: KClass<T>, content: @Composable ListItemScope.(item: T) -> Unit): ListCellRenderer<*>

Remembers the renderer that stamps content for every item of a component it is installed on, for a caller who names itemType rather than letting the call site reify it - a generic component of their own, whose item type is a type parameter and so is erased by the time this call is compiled.

Link copied to clipboard
@Composable
fun rememberListState(initialSelectedIndices: Set<Int> = emptySet()): ListState

Creates and remembers a ListState starting on initialSelectedIndices.

Link copied to clipboard
@Composable
fun rememberTableState(initialSelectedRowIndices: Set<Int> = emptySet()): TableState

Creates and remembers a TableState starting on initialSelectedRowIndices.

Link copied to clipboard
@Composable
fun rememberTreeState(initialSelectedPaths: Set<List<Int>> = emptySet(), initialExpandedPaths: Set<List<Int>> = emptySet()): TreeState

Creates and remembers a TreeState starting on initialSelectedPaths and initialExpandedPaths.

Link copied to clipboard
@Composable
fun Table(model: TableModel, state: TableState, modifier: SwingModifier = SwingModifier, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, sortable: Boolean = false, sortKeys: List<RowSorter.SortKey>? = null, onSortChange: (List<RowSorter.SortKey>) -> Unit = {}, rowFilter: RowFilter<in TableModel, in Int>? = null, rowHeight: Int? = null, autoResizeMode: Int = JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, fillsViewportHeight: Boolean = false, columnLayout: TableColumnLayout? = null, onColumnLayoutChange: (TableColumnLayout) -> Unit = {})

A model-driven Table driven by a TableState instead of a declared selectedRowIndices and an onSelectionChange lambda. The state owns the selection: the rows it holds are what the table shows selected, the user's own selecting is written back into it, and it is where a row is revealed from.

@Composable
fun Table(model: TableModel, listSelectionListener: ListSelectionListener, modifier: SwingModifier = SwingModifier, selectedRowIndices: Set<Int>? = null, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, sortable: Boolean = false, sortKeys: List<RowSorter.SortKey>? = null, rowSorterListener: RowSorterListener? = null, rowFilter: RowFilter<in TableModel, in Int>? = null, rowHeight: Int? = null, autoResizeMode: Int = JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, fillsViewportHeight: Boolean = false, columnLayout: TableColumnLayout? = null, tableColumnModelListener: TableColumnModelListener? = null)

A model-driven Table driven by raw listeners instead of the onSelectionChange/onSortChange/onColumnLayoutChange lambdas. The selection listener observes the table's selectionModel, so it sees the adjusting events of a drag as well as the settled one. A listener is notified of the user's own changes only, and of what a model swap took away from the user; each is removed on the same instance, so pass a stable one (e.g. remember {}) to avoid churn.

@Composable
fun Table(model: TableModel, modifier: SwingModifier = SwingModifier, selectedRowIndices: Set<Int>? = null, onSelectionChange: (Set<Int>) -> Unit = {}, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, sortable: Boolean = false, sortKeys: List<RowSorter.SortKey>? = null, onSortChange: (List<RowSorter.SortKey>) -> Unit = {}, rowFilter: RowFilter<in TableModel, in Int>? = null, rowHeight: Int? = null, autoResizeMode: Int = JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, fillsViewportHeight: Boolean = false, columnLayout: TableColumnLayout? = null, onColumnLayoutChange: (TableColumnLayout) -> Unit = {})

A grid the user reads, sorts, and selects in, over a TableModel the caller owns: a JTable reporting the selection, the sort order, and the column layout the user leaves it in.

@Composable
fun <R> Table(rows: List<R>, state: TableState, modifier: SwingModifier = SwingModifier, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, sortable: Boolean = false, sortKeys: List<RowSorter.SortKey>? = null, onSortChange: (List<RowSorter.SortKey>) -> Unit = {}, rowFilter: RowFilter<in TableModel, in Int>? = null, rowHeight: Int? = null, autoResizeMode: Int = JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, fillsViewportHeight: Boolean = false, columnLayout: TableColumnLayout? = null, onColumnLayoutChange: (TableColumnLayout) -> Unit = {}, block: TableScope<R>.() -> Unit)

A Table driven by a TableState instead of a declared selectedRowIndices and an onSelectionChange lambda. The state owns the selection: the rows it holds are what the table shows selected, the user's own selecting is written back into it, and it is where a row is revealed from.

@Composable
fun <R> Table(rows: List<R>, listSelectionListener: ListSelectionListener, modifier: SwingModifier = SwingModifier, selectedRowIndices: Set<Int>? = null, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, sortable: Boolean = false, sortKeys: List<RowSorter.SortKey>? = null, rowSorterListener: RowSorterListener? = null, rowFilter: RowFilter<in TableModel, in Int>? = null, rowHeight: Int? = null, autoResizeMode: Int = JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, fillsViewportHeight: Boolean = false, columnLayout: TableColumnLayout? = null, tableColumnModelListener: TableColumnModelListener? = null, block: TableScope<R>.() -> Unit)

A Table driven by raw listeners instead of the onSelectionChange/onSortChange/onColumnLayoutChange lambdas. The selection listener observes the table's selectionModel, so it sees the adjusting events of a drag as well as the settled one. A listener is notified of the user's own changes only, and of what a rebuild of the rows or the columns took away from the user; each is removed on the same instance, so pass a stable one (e.g. remember {}) to avoid churn.

@Composable
fun <R> Table(rows: List<R>, modifier: SwingModifier = SwingModifier, selectedRowIndices: Set<Int>? = null, onSelectionChange: (Set<Int>) -> Unit = {}, selectionMode: Int = ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, sortable: Boolean = false, sortKeys: List<RowSorter.SortKey>? = null, onSortChange: (List<RowSorter.SortKey>) -> Unit = {}, rowFilter: RowFilter<in TableModel, in Int>? = null, rowHeight: Int? = null, autoResizeMode: Int = JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, fillsViewportHeight: Boolean = false, columnLayout: TableColumnLayout? = null, onColumnLayoutChange: (TableColumnLayout) -> Unit = {}, block: TableScope<R>.() -> Unit)

A grid the user reads, sorts, and selects in: a JTable reporting the selection, the sort order, and the column layout the user leaves it in.

Link copied to clipboard
@Composable
fun Tree(model: TreeModel, state: TreeState, modifier: SwingModifier = SwingModifier, selectionMode: Int = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible: Boolean = true, showsRootHandles: Boolean? = null, rowHeight: Int? = null, visibleRowCount: Int = 20, toggleClickCount: Int = 2)

A model-driven Tree driven by a TreeState instead of declared selectedPaths/expandedPaths and the onSelectionChange/onExpansionChange lambdas. The state owns both facets: the nodes it holds are what the tree shows selected and open, the user's own selecting and opening is written back into it, and it is where a node is revealed from.

@Composable
fun Tree(model: TreeModel, treeSelectionListener: TreeSelectionListener, modifier: SwingModifier = SwingModifier, selectedPaths: Set<List<Int>>? = null, expandedPaths: Set<List<Int>>? = null, treeExpansionListener: TreeExpansionListener? = null, selectionMode: Int = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible: Boolean = true, showsRootHandles: Boolean? = null, rowHeight: Int? = null, visibleRowCount: Int = 20, toggleClickCount: Int = 2)

A model-driven Tree driven by raw listeners instead of the onSelectionChange/onExpansionChange lambdas. A listener is notified of the user's changes only - the selection listener also of a selection a new model took away from the user - and is removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn.

@Composable
fun Tree(model: TreeModel, modifier: SwingModifier = SwingModifier, selectedPaths: Set<List<Int>>? = null, onSelectionChange: (Set<List<Int>>) -> Unit = {}, expandedPaths: Set<List<Int>>? = null, onExpansionChange: (Set<List<Int>>) -> Unit = {}, selectionMode: Int = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible: Boolean = true, showsRootHandles: Boolean? = null, rowHeight: Int? = null, visibleRowCount: Int = 20, toggleClickCount: Int = 2)

A hierarchy the user opens and selects in, over a TreeModel the caller owns: a JTree reporting what the user selects and opens.

@Composable
fun <T> Tree(root: T, children: (T) -> List<T>, state: TreeState, modifier: SwingModifier = SwingModifier, label: (T) -> @Nls String = { it.toString() }, hasChildren: (T) -> Boolean? = null, onWillExpand: (value: T, path: List<Int>) -> Boolean? = null, isEditable: Boolean = false, onNodeEdit: (value: T, path: List<Int>, newValue: Any?) -> Unit = { _, _, _ -> }, selectionMode: Int = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible: Boolean = true, showsRootHandles: Boolean? = null, rowHeight: Int? = null, visibleRowCount: Int = 20, toggleClickCount: Int = 2, nodeContent: @Composable TreeNodeScope.(value: T) -> Unit? = null)

A Tree driven by a TreeState instead of declared selectedPaths/expandedPaths and the onSelectionChange/onExpansionChange lambdas. The state owns both facets: the nodes it holds are what the tree shows selected and open, the user's own selecting and opening is written back into it, and it is where a node is revealed from.

@Composable
fun <T> Tree(root: T, children: (T) -> List<T>, treeSelectionListener: TreeSelectionListener, modifier: SwingModifier = SwingModifier, label: (T) -> @Nls String = { it.toString() }, hasChildren: (T) -> Boolean? = null, selectedPaths: Set<List<Int>>? = null, expandedPaths: Set<List<Int>>? = null, treeExpansionListener: TreeExpansionListener? = null, treeWillExpandListener: TreeWillExpandListener? = null, isEditable: Boolean = false, onNodeEdit: (value: T, path: List<Int>, newValue: Any?) -> Unit = { _, _, _ -> }, selectionMode: Int = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible: Boolean = true, showsRootHandles: Boolean? = null, rowHeight: Int? = null, visibleRowCount: Int = 20, toggleClickCount: Int = 2, nodeContent: @Composable TreeNodeScope.(value: T) -> Unit? = null)

A Tree driven by raw listeners instead of the onSelectionChange/onExpansionChange/onWillExpand lambdas. A listener is notified of the user's changes only - the selection listener also of a selection a new structure took away from the user - and is removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. The will-expand listener hears more than the user: it is announced every expansion and every collapse, the ones a declaration applies as much as the ones the user asks for, and vetoes the one it refuses by throwing an ExpandVetoException.

@Composable
fun <T> Tree(root: T, children: (T) -> List<T>, modifier: SwingModifier = SwingModifier, label: (T) -> @Nls String = { it.toString() }, hasChildren: (T) -> Boolean? = null, selectedPaths: Set<List<Int>>? = null, onSelectionChange: (Set<List<Int>>) -> Unit = {}, expandedPaths: Set<List<Int>>? = null, onExpansionChange: (Set<List<Int>>) -> Unit = {}, onWillExpand: (value: T, path: List<Int>) -> Boolean? = null, isEditable: Boolean = false, onNodeEdit: (value: T, path: List<Int>, newValue: Any?) -> Unit = { _, _, _ -> }, selectionMode: Int = TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION, rootVisible: Boolean = true, showsRootHandles: Boolean? = null, rowHeight: Int? = null, visibleRowCount: Int = 20, toggleClickCount: Int = 2, nodeContent: @Composable TreeNodeScope.(value: T) -> Unit? = null)

A hierarchy the user opens and selects in: a JTree built from data, reporting what the user selects, opens, and edits.