Containers
| Tag | Class | Notes |
|---|---|---|
| frame | com.ooi.swing.Frame | A subclass of JFrame. This tag has special handling for the menubar and content pane. |
| pane | com.ooi.swing.Pane | A panel with support for java.awt.Paint, uses border layout |
| hpane | com.ooi.swing.Pane | Uses horizontal linear layout |
| vpane | com.ooi.swing.Pane | Uses vertical linear layout |
| glass | com.ooi.swing.Glass | A simple clear component |
| watermark | com.ooi.swing.WatermarkPane | A pane that supports a watermark background |
| scroll | com.ooi.swing.ScrollPane | |
| tabs | javax.swing.JTabbedPane | |
| split | javax.swing.JSplitPane |
Notes: Container class layout managers can be set with the "layout" magic property like so:
pane layout="border" // this is the default, so it need not be specified
pane layout="spring"
pane layout="horizontal"
pane layout="horizontal(5)" // horizontal layout with 5 pixels between components
pane layout="vertical"
pane layout="grid(5,3)"
pane layout="table(fill,fill,fill,fill|pref,pref,pref,pref,fill)"
The "loc" magic property allow constraints to be used when adding components. For example:
pane {
button "Hello" loc="north"
textarea
label "Foo" loc="south"
}
The vertical and horizontal layouts support a "fill" constraint that indicates the component should fill available space.
Text Related
| Tag | Class | Notes |
|---|---|---|
| label | com.ooi.swing.Label | |
| vlabel | com.ooi.swing.VerticalLabel | |
| multilabel | com.ooi.swing.MultiLabel | A multi-line label |
| titlepane | com.ooi.swing.TitledPane | |
| text | com.ooi.swing.TextField | |
| textarea | javax.swing.JTextArea | |
| textpane | javax.swing.JTextPane | |
| password | javax.swing.JPasswordField |
Note: Labels can also be created simply by using a string literal. Example:
hpane {
"This is a label"
}
Menu and Toolbar Related
| Tag | Class | Notes |
|---|---|---|
| menus | javax.swing.JMenuBar | |
| toolbar | javax.swing.JToolBar | |
| menu | javax.swing.JMenu | |
| menuitem | javax.swing.JMenuItem | |
| checkmenuitem | javax.swing.JCheckBoxMenuItem | |
| radiomenuitem | javax.swing.JRadioButtonMenuItem | |
| separator | com.ooi.swing.Separator |
Menus can also be created by simply using strings like so:
menus {
"Colors" {
"Red"
"Green"
"Blue"
}
"Textures" {
"Fluffy"
"Rough"
}
}
Radio button menus are created like so:
menus {
"Colors" {
radios {
"Red"
"Green"
"Blue"
}
}
}
Button Related
| Tag | Class | Notes |
|---|---|---|
| button | com.ooi.swing.Button | |
| toggle | javax.swing.JToggleButton | |
| radio | javax.swing.JRadioButton | |
| check | javax.swing.JCheckBox |
Radio buttons can be specified like so:
hpane {
radios group="gender" {
"Male"
"Female"
}
}
You can get a handle on the ButtonGroup using the form object:
ButtonGroup = form.getGroup("gender");
Trees and Tables
| Tag | Class | Notes |
|---|---|---|
| tree | javax.swing.JTree | |
| table | javax.swing.JTable |
Misc
| Tag | Class | Notes |
|---|---|---|
| spacer | com.ooi.swing.Glass | Takes a single int argument (e.g. spacer 5) to create a space between components |
| combo | javax.swing.JComboBox | |
| spinner | javax.swing.JSpinner | |
| slider | javax.swing.JSlider | |
| progress | javax.swing.JProgressBar | |
| list | javax.swing.JList | |
| form | com.ooi.swing.Form | A root container for fetching child components by name |
| formpane | com.ooi.swing.FormPane | Supports simple form layout |
| ref | N/A | A tag that loads the component named in the string that follows (see below) |
The ref tag loads an sdl definition for a component from the /resources/components/ project directory. Example:
pane {
ref "menubar" loc="north"
pane {
...
}
}
The code above loads /resources/components/menubar.sdl and adds it to a pane with the constraint BorderLayout.NORTH.
