You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lib-swing is a RichTea library for building desktop GUI applications using Java Swing. It provides declarative RichTea functions for every major Swing component, with event handling wired directly to RichTea branches.
Components
Container components
Function
Swing class
Implicit attr/branch
Description
Frame
JFrame
title / :content
Top-level application window.
Panel
JPanel
— / :content
General-purpose container.
SplitPane
JSplitPane
— / :content
Two-pane split container. Requires exactly two children.
ScrollPane
JScrollPane
— / :content
Scrollable wrapper around a single child.
TabbedPane
JTabbedPane
— / :content
Tabbed container; child component names become tab titles.
Control components
Function
Swing class
Implicit attr
Description
Label
JLabel
text
Static text label.
Button
JButton
text
Clickable button.
RadioButton
JRadioButton
text
Radio button; use buttonGroup to group.
ComboBox
JComboBox
data
Drop-down list populated from a RichTea array.
Slider
JSlider
—
Slider control.
TextField
JTextField
text
Single-line text input.
TextArea
JTextArea
text
Multi-line text input.
Menu components
Function
Swing class
Implicit attr
Description
MenuBar
JMenuBar
— / :content
Top-level menu bar.
Menu
JMenu
text / :content
Drop-down menu inside a MenuBar.
MenuItem
JMenuItem
text
Clickable item inside a Menu.
MenuItemRadioButton
JRadioButtonMenuItem
text
Radio-button menu item.
Layout managers
Function
Java class
Description
FlowLayout
java.awt.FlowLayout
Flows components left-to-right.
BorderLayout
java.awt.BorderLayout
North/South/East/West/Center regions.
GridLayout
java.awt.GridLayout
Fixed-size grid of cells.
Common Attributes (all components)
All components inherit from CreateAWTComponent and support:
Attribute
Description
x
X position in the parent container (default: 0).
y
Y position in the parent container (default: 0).
width
Component width in pixels (default: preferred width).
height
Component height in pixels (default: preferred height).
name
Component name, used as the tab title in TabbedPane.
Events
All components automatically wire up RichTea branches for every supported Swing event. To respond to an event, add a branch whose name matches the event.
Supported events (all components)
Branch name
Fired when
:actionPerformed
Button clicked, menu item selected, combo selection changed.
:mouseClicked
Mouse button clicked.
:mousePressed
Mouse button pressed.
:mouseReleased
Mouse button released.
:mouseEntered
Cursor entered the component.
:mouseExited
Cursor left the component.
:keyPressed
Key pressed while component has focus.
:keyReleased
Key released while component has focus.
:keyTyped
Key typed (pressed and released).
:focusGained
Component gained keyboard focus.
:focusLost
Component lost keyboard focus.
:itemStateChanged
Selection state changed (checkboxes, combo boxes).