Create desktop applications using Java Swing components. Access via GUI namespace.
Base structure for all elements.
show(), hide(), setVisible(boolean)setSize(width, height)setText(text), getText()setBackground(color), setForeground(color)setEnabled(boolean), isEnabled()Base structure for elements that hold other components.
add(component, [constraints])remove(component)setLayout(type, [rows, cols])GUI.Window([title])GUI.Dialog([title]) (Can be set modal via setModal(boolean))GUI.Panel()GUI.ScrollPane([view])GUI.SplitPane([orientation]) (Horizontal by default)GUI.ToolBar()GUI.TabbedPane(): Add tabs via addTab(title, component)GUI.Button(text), GUI.ToggleButton(text)GUI.CheckBox(text), GUI.RadioButton(text)GUI.Label(text), GUI.TextField([text]), GUI.TextArea([text])GUI.ComboBox(), GUI.List(), GUI.Slider([min, max, value]), GUI.ProgressBar([min, max])GUI.Tree() (Uses GUI.TreeNode), GUI.ColorChooser(), GUI.FileChooser()GUI.MenuBar()GUI.Menu(text): Add to MenuBar, responds to onSelect(...)GUI.MenuItem(text): Responds to onAction(...)| Event Registration | Callback Signature |
|---|---|
comp.onClick("funcName") | funcName() |
comp.onMouse("funcName") | funcName(type, x, y, button, clickCount) |
comp.onKey("funcName") | funcName(type, keyCode, keyChar, modifiers) |
menu.onSelect("funcName") | funcName(action) |
win = GUI.Window("My App");
panel = GUI.Panel();
btn = GUI.Button("Click Me");
function onClick(type, x, y, btn, c) {
print("Clicked!");
}
btn.onMouse("onClick");
panel.add(btn);
win.add(panel);
win.setSize(300, 200);
win.show();