Package-level declarations

Types

Link copied to clipboard
class TrayMenuHost(parentContext: CompositionContext, display: (popup: JPopupMenu, x: Int, y: Int) -> Unit = ::showPopupAtCursor, menu: @Composable () -> Unit)

Builds and presents the popup menu of a Tray. On each showMenu call it composes menu fresh into a JPopupMenu nested in parentContext, so the menu reflects the current composition state, then hands the populated popup to display. The menu composition is disposed when the popup closes, when a newer showMenu call replaces it, or when closeMenu closes it.

Functions

Link copied to clipboard
@Composable
fun Canvas(modifier: SwingModifier = SwingModifier, onDraw: (g: Graphics2D, width: Int, height: Int) -> Unit)

A composable that hands you the raw Graphics2D of a blank Swing surface so you can draw whatever you like.

Link copied to clipboard
@Composable
fun <T> ComboBox(model: ComboBoxModel<T>, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, editable: Boolean = false, maximumRowCount: Int? = null, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A model-driven ComboBox driven by a raw ActionListener instead of an onSelectionChange lambda. The model owns its items and selection and is never mutated by the library. The actionListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. Swapping the model instance installs the new model verbatim.

@Composable
fun <T> ComboBox(model: ComboBoxModel<T>, modifier: SwingModifier = SwingModifier, onSelectionChange: (Int) -> Unit = {}, editable: Boolean = false, onValueCommit: (@Nls String) -> Unit = {}, maximumRowCount: Int? = null, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A ComboBox driven by a caller-owned ComboBoxModel. The model owns both the items and the selection, so this overload is observation-only: it renders the model and reports selection changes through onSelectionChange without ever writing the selection back into the model. Swapping the model instance installs the new model verbatim.

@Composable
fun <T> ComboBox(items: List<T>, selectedItem: T?, actionListener: ActionListener, modifier: SwingModifier = SwingModifier, editable: Boolean = false, maximumRowCount: Int? = null, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A ComboBox driven by a raw ActionListener instead of an onSelectionChange lambda. The actionListener 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 action event the combo box fires, including the one that applies selectedItem. selectedItem is declared, applied and re-asserted as on the onSelectionChange-driven overload.

@Composable
fun <T> ComboBox(items: List<T>, selectedItem: T?, onSelectionChange: (T?) -> Unit, modifier: SwingModifier = SwingModifier, editable: Boolean = false, onValueCommit: (@Nls String) -> Unit = {}, maximumRowCount: Int? = null, itemContent: @Composable ListItemScope.(item: T) -> Unit? = null)

A JComboBox over items: it shows the item that is selected and drops the full list down in a popup for the user to choose from.

Link copied to clipboard
@Composable
fun Label(text: @Nls String, modifier: SwingModifier = SwingModifier)

A JLabel showing text: non-interactive text, which the Tab focus cycle skips, though a focus request still lands on it.

Link copied to clipboard
@Composable
fun ProgressBar(model: BoundedRangeModel, modifier: SwingModifier = SwingModifier, indeterminate: Boolean = false, orientation: Int = SwingConstants.HORIZONTAL, stringPainted: Boolean = false, string: @Nls String? = null)

A JProgressBar reporting the progress a caller-owned BoundedRangeModel holds. The model owns the value and the range, so nothing is declared over it: the bar renders whatever the model holds, and a model the caller mutates repaints the bar without a recomposition. Supplying a new model instance installs it on recomposition.

@Composable
fun ProgressBar(value: Int, modifier: SwingModifier = SwingModifier, min: Int = 0, max: Int = 100, indeterminate: Boolean = false, orientation: Int = SwingConstants.HORIZONTAL, stringPainted: Boolean = false, string: @Nls String? = null)

A JProgressBar reporting how far along a task is: it fills in proportion to where value stands between min and max. The user changes nothing here - the bar renders what the composition declares and reports nothing back.

Link copied to clipboard
@Composable
fun Separator(modifier: SwingModifier = SwingModifier, orientation: Int = SwingConstants.HORIZONTAL)

A JSeparator: the divider line that breaks the items of any container into groups. A tool bar takes its own divider - see org.jetbrains.compose.swing.components.layout.ToolBarSeparator.

Link copied to clipboard
@Composable
fun Slider(model: BoundedRangeModel, changeListener: ChangeListener, modifier: SwingModifier = SwingModifier, orientation: Int = SwingConstants.HORIZONTAL, inverted: Boolean = false, majorTickSpacing: Int = 0, minorTickSpacing: Int = 0, paintTicks: Boolean = false, paintLabels: Boolean = false, labels: Map<Int, @Nls String>? = null, snapToTicks: Boolean = false)

A model-driven Slider driven by a raw ChangeListener instead of the onValueChange and onValueSettled lambdas. The model is rendered as-is and never written to by the library. The changeListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn, and read getValueIsAdjusting off the slider to tell the values a drag passes through from the one it settles on.

@Composable
fun Slider(model: BoundedRangeModel, modifier: SwingModifier = SwingModifier, onValueChange: (Int) -> Unit = {}, onValueSettled: (Int) -> Unit = {}, orientation: Int = SwingConstants.HORIZONTAL, inverted: Boolean = false, majorTickSpacing: Int = 0, minorTickSpacing: Int = 0, paintTicks: Boolean = false, paintLabels: Boolean = false, labels: Map<Int, @Nls String>? = null, snapToTicks: Boolean = false)

A Slider over a caller-owned BoundedRangeModel. The model owns the value and the range, so nothing is declared over it: the slider renders whatever the model holds, the library never writes to it, and a model the caller mutates repaints the slider without a recomposition. Supplying a new model instance installs it on recomposition.

@Composable
fun Slider(value: Int, changeListener: ChangeListener, modifier: SwingModifier = SwingModifier, min: Int = 0, max: Int = 100, orientation: Int = SwingConstants.HORIZONTAL, inverted: Boolean = false, majorTickSpacing: Int = 0, minorTickSpacing: Int = 0, paintTicks: Boolean = false, paintLabels: Boolean = false, labels: Map<Int, @Nls String>? = null, snapToTicks: Boolean = false)

A Slider driven by a raw ChangeListener instead of the onValueChange and onValueSettled lambdas. The changeListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid a detach/re-attach on every recomposition. Being attached as-is, it is notified of every change to the slider's value - the values a drag passes through as well as the one it settles on, and the change that applies value included - and reads getValueIsAdjusting off the slider to tell them apart.

@Composable
fun Slider(value: Int, onValueChange: (Int) -> Unit, modifier: SwingModifier = SwingModifier, onValueSettled: (Int) -> Unit = {}, min: Int = 0, max: Int = 100, orientation: Int = SwingConstants.HORIZONTAL, inverted: Boolean = false, majorTickSpacing: Int = 0, minorTickSpacing: Int = 0, paintTicks: Boolean = false, paintLabels: Boolean = false, labels: Map<Int, @Nls String>? = null, snapToTicks: Boolean = false)

A JSlider: the user picks a whole number between min and max by dragging a knob along a track. A value the user leaves the knob on and the caller does not answer with a matching value is settled back onto the declared one once the drag is released, so the knob ends where the composition says.

Link copied to clipboard
@Composable
fun Spinner(model: SpinnerModel, changeListener: ChangeListener, modifier: SwingModifier = SwingModifier, format: String? = null, editor: @Composable () -> Unit? = null)

A JSpinner over a caller-owned model, driven by a raw changeListener rather than by a value the spinner reports back. The changeListener is attached as-is and removed on the same instance; pass a stable instance (e.g. remember {}) to avoid churn. Swapping the model instance installs the new model verbatim.

@Composable
fun <T : Any> Spinner(items: List<T>, value: T?, onValueChange: (T) -> Unit, modifier: SwingModifier = SwingModifier, editor: @Composable () -> Unit? = null)

A JSpinner over items: it shows the one selected value in an editable field beside a pair of arrows that step from one item to the next, without wrapping at either end. Text typed at the end of the field is completed to the next item starting with it, so a distinguishing prefix is enough to commit one.

@Composable
fun Spinner(value: Date, onValueChange: (Date) -> Unit, modifier: SwingModifier = SwingModifier, start: Date? = null, end: Date? = null, calendarField: Int = Calendar.DAY_OF_MONTH, format: String? = null, editor: @Composable () -> Unit? = null)

A JSpinner over dates: it shows value in an editable field beside a pair of arrows that step it by one calendarField, through a SpinnerDateModel built from start and end.

@Composable
fun Spinner(value: Number, onValueChange: (Number) -> Unit, modifier: SwingModifier = SwingModifier, min: Number? = null, max: Number? = null, step: Number = 1, format: String? = null, editor: @Composable () -> Unit? = null)

A JSpinner over numbers: it shows value in an editable field beside a pair of arrows that step it by step, through a SpinnerNumberModel built from min, max and step. A value the user leaves the spinner on and the caller does not answer with a matching value is settled back onto the declared one, so the spinner shows what the composition holds.

Link copied to clipboard
@Composable
fun Tray(image: Image, onAction: () -> Unit, tooltip: @Nls String? = null, imageAutoSize: Boolean = false, menu: @Composable () -> Unit = {})

Registers a system-tray icon for the lifetime of this composition.