Button.java | Class | A Button is a component that typically causes an action when activated.
Example:
Button b = new Button("Click Me!");
b.setBounds(20, 20, 150, 30);
b.addActionListener(Button.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent e) {
((Button) e.getSource()).setText("You Clicked Me!");
}
});
Dialog d = new Dialog("Button Test");
d.setBounds(20, 20, 200, 100);
d.getChildren().add(b);
d.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Space |
Fires ActionEvent( action = Button.ACTION_CLICK ) |
Only if the component has focus. |
Enter |
Fires ActionEvent( action = Button.ACTION_CLICK ) |
Only if the 'standard' property is set to 'true' and ANY component in the Window has focus. | CheckBox.java | Class | A CheckBox is a screen element that can either be checked or cleared, and operates independently of other elements.
Example:
final CheckBox cb = new CheckBox("I am checked!");
cb.setChecked(true);
cb.setBounds(20, 20, 150, 30);
cb.addPropertyChangeListener(CheckBox.PROPERTY_CHECKED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent pce) {
if (pce.getNewValue() == Boolean.TRUE) {
cb.setText("I am checked");
} else {
cb.setText("I am unchecked");
}
}
});
Dialog d = new Dialog("CheckBox Test");
d.setBounds(20, 20, 200, 100);
d.getChildren().add(cb);
d.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Space |
Fires PropertyChangeEvent( propertyName = CheckBox.PROPERTY_CHECKED ) |
Only if the component has focus. |
author: Joshua J. | CheckedComponent.java | Interface | author: Joshua J. | Component.java | Interface | Component is the foundation of all visual objects in the framework. | Container.java | Interface | A Container is a Component that maintains a collection of other Component s as a group.
Additionally, Container is the foundation of all other container types in the framework such as Panel , Frame ,
Dialog , TabSheet , etc. | DateBox.java | Class | A DateBox is a Component that displays a
month-view calendar. | Dialog.java | Class | A Dialog is a window with a title that is usually associated to a Frame.
Example:
Dialog dlg = new Dialog("Dialog Test");
dlg.setBounds(25, 25, 600, 400);
final TextField tBox = new TextField();
tBox.setBounds(25, 25, 150, 20);
dlg.getChildren().add(tBox);
final Button btn1 = new Button("Add Text");
btn1.setBounds(200, 20, 100, 30);
dlg.getChildren().add(btn1);
final Button btn2 = new Button("Numeric Mask");
btn2.setBounds(310, 20, 100, 30);
dlg.getChildren().add(btn2);
final Button btn3 = new Button("Right Align");
btn3.setBounds(420, 20, 100, 30);
dlg.getChildren().add(btn3);
ActionListener clickListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Button btn = (Button) e.getSource();
if (btn == btn1) {
tBox.setText(tBox.getText() + "913JQP-");
} else if (btn == btn2) {
tBox.setEditMask("#########");
} else if (btn == btn3) {
tBox.setAlignX(AlignX.RIGHT);
}
}
};
btn1.addActionListener(Button.ACTION_CLICK, clickListener);
btn2.addActionListener(Button.ACTION_CLICK, clickListener);
btn3.addActionListener(Button.ACTION_CLICK, clickListener);
Divider dv = new Divider();
dv.setBounds(25, 70, 550, 5);
dlg.getChildren().add(dv);
final TextArea ta = new TextArea();
ta.setBounds(25, 100, 350, 200);
dlg.getChildren().add(ta);
Button btn4 = new Button("Add Text");
btn4.setBounds(420, 100, 100, 30);
dlg.getChildren().add(btn4);
btn4.addActionListener(Button.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent e) {
ta.setText(ta.getText() + "913JQP-");
}
});
dlg.setVisible(true);
author: Joshua J. | Divider.java | Class | A Divider provides a visual separation between two sections of a container.
Example:
Dialog dlg = new Dialog("Divider Test");
dlg.setBounds(25, 25, 250, 150);
Divider horizDiv = new Divider();
horizDiv.setBounds(10, 10, 210, 10);
dlg.getChildren().add(horizDiv);
Divider vertDiv = new Divider();
vertDiv.setBounds(110, 30, 10, 90);
dlg.getChildren().add(vertDiv);
dlg.setVisible(true);
author: Joshua J. | DropDown.java | Class | The generic DropDown component allows you to place an
arbitrary component in a DropDown . | DropDownDateBox.java | Class | A DropDownDateBox is a DropDown that contains
a DateBox .
Example:
final Dialog dlg = new Dialog("DateBox Test");
dlg.setBounds(10, 10, 320, 240);
DropDownDateBox dd = new DropDownDateBox();
dd.setBounds(10, 10, 200, 20);
dlg.getChildren().add(dd);
dlg.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Down Arrow |
Drops the DateBox down. |
Only if the component has focus. |
Esc |
Closes the DateBox |
Only if the component has focus. |
See DateBox for additional keyboard support.
author: Ted C. | DropDownGridBox.java | Class | A DropDownGridBox wraps around a GridBox component to provide drop down
features.
Example:
Dialog dlg = new Dialog("DropDownGridBox Test");
dlg.setBounds(25, 25, 400, 200);
final TextField tf = new TextField();
tf.setBounds(275, 25, 100, 20);
dlg.getChildren().add(tf);
DropDownGridBox ddgb = new DropDownGridBox();
ddgb.setBounds(25, 25, 230, 20);
GridBox gb = ddgb.getComponent();
gb.setVisibleHeader(true);
gb.setHeight(120);
GridBox.Column col1 = new GridBox.Column();
col1.setName("Name");
GridBox.Column col2 = new GridBox.Column();
col2.setName("City");
GridBox.Column col3 = new GridBox.Column();
col3.setName("Country");
gb.getColumns().add(col1);
gb.getColumns().add(col2);
gb.getColumns().add(col3);
String[] names = { "Smythe", "Janes", "Warren", "Dempster", "Hilcox" };
String[] cities = { "Tokyo", "Hong Kong", "Lethbridge", "Juarez", "Juneau" };
String[] countries = { "Japan", "China", "Canada", "Mexico", "USA" };
for (int r = 0; r < 5; r++) {
GridBox.Row row = new GridBox.Row();
row.add(names[r]);
row.add(cities[r]);
row.add(countries[r]);
gb.getRows().add(row);
}
((DropDownGridBox.DefaultView) ddgb.getView()).setColumnIndex(2);
ddgb.addPropertyChangeListener(DropDownGridBox.PROPERTY_TEXT,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
tf.setText((String) evt.getNewValue());
}
});
dlg.getChildren().add(ddgb);
dlg.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Down Arrow |
Drops the Grid Box down. |
Only if the component has focus. |
Esc |
Closes the Grid Box |
Only if the component has focus. |
See GridBox for additional keyboard support.
author: Joshua J. | EditorComponent.java | Interface | author: Joshua J. | EventListenerImpl.java | Class | author: Joshua J. | FileChooser.java | Class | A FileChooser is a Component that enables a user to upload a
file. | Frame.java | Class | A Frame is the browser window. | GridBox.java | Class | A GridBox is a screen component that can display multi-column rows or data.
Example:
Dialog dlg = new Dialog("GridBox Test");
dlg.setBounds(25, 25, 600, 300);
final TextField tf = new TextField();
tf.setBounds(375, 25, 150, 20);
dlg.getChildren().add(tf);
GridBox gbx = new GridBox();
gbx.setBounds(25, 25, 300, 120);
gbx.setVisibleHeader(true);
gbx.setVisibleCheckBoxes(true);
gbx.setFullRowCheckBox(true);
GridBox.Column col1 = new GridBox.Column();
col1.setName("Name");
col1.setVisible(true);
GridBox.Column col2 = new GridBox.Column();
col2.setName("City");
col2.setVisible(true);
gbx.getColumns().add(col1);
gbx.getColumns().add(col2);
String[] names = { "Smythe", "Janes", "Warren", "Dempster", "Hilcox" };
String[] cities = { "Tokyo", "Hong Kong", "Lethbridge", "Moose Jaw", "Red Deer" };
for (int r = 0; r < 5; r++) {
GridBox.Row row = new GridBox.Row();
row.add(names[r]);
row.add(cities[r]);
gbx.getRows().add(row);
}
gbx.addPropertyChangeListener(GridBox.Row.PROPERTY_ROW_SELECTED,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
tf.setText((String) ((GridBox.Row) evt.getSource()).get(0));
}
});
dlg.getChildren().add(gbx);
dlg.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Space |
Fires PropertyChangeEvent( propertyName = GridBox.Row.PROPERTY_CHECKED ) |
Only if isVisibleCheckBoxes() is true. |
Enter |
Fires Action( actionName = GridBox.ACTION_CLICK ) |
|
Arrow Up/Down |
Fires PropertyChangeEvent( propertyName = GridBox.Row.PROPERTY_SELECTED ) |
|
author: Joshua J. | HierarchyComponent.java | Interface | author: Joshua J. | Hyperlink.java | Class | A Hyperlink is a screen component that acts like a standard
hyperlink.
Example:
Hyperlink hl = new Hyperlink("Custom Credit Systems Home Page",
"http://www.customcreditsystems.com");
hl.setBounds(25, 25, 175, 20);
MessageBox.confirm("", "Hyperlink Test", hl, "OK");
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Enter |
Fires Action( Action = Hyperlink.ACTION_CLICK ) |
Only if the component has focus. |
author: Joshua J. | Image.java | Class | A component that displays an image. | ImageComponent.java | Interface | author: Joshua J. | ItemChangeEventComponent.java | Interface | author: Joshua J. | Label.java | Class | A Label is the text that appears next to a control on a
screen.
Example:
Dialog dlg = new Dialog("Label Test");
dlg.setBounds(25, 25, 415, 150);
final Label lbl = new Label("Initial 1st Label");
lbl.setBounds(25, 25, 150, 30);
Button btn = new Button("Toggle Text");
btn.setBounds(300, 20, 100, 30);
btn.addActionListener(Button.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent ev) {
if ("Initial 1st Label".equals(lbl.getText())) {
lbl.setText("The text has now been toggled.");
} else {
lbl.setText("Initial 1st Label");
}
}
});
dlg.getChildren().add(lbl);
dlg.getChildren().add(btn);
dlg.setVisible(true);
Keyboard Navigation:
author: Joshua J. | MaskEditorComponent.java | Interface | author: Joshua J. | Menu.java | Class | A component that displays a set of hierarchical data as a menu.
Example:
Dialog dlg = new Dialog("Menu Test");
dlg.setBounds(25, 25, 200, 200);
Menu mainMenu = new Menu();
Menu.Item fileItem = new Menu.Item("File");
Menu.Item newItem = new Menu.Item("New");
newItem.setUserObject("You clicked on the File->New menu item");
Menu.Item openItem = new Menu.Item("Open");
openItem.setUserObject("You clicked on the File->Open menu item");
mainMenu.addActionListener(Menu.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Menu.Item selectedItem = (Menu.Item) ev.getSource();
MessageBox.confirm("resources/ngLF/system.png", "Menu Test", (String) selectedItem.getUserObject());
}
});
dlg.setMenu(mainMenu);
mainMenu.getRootItem().getChildren().add(fileItem);
fileItem.getChildren().add(newItem);
fileItem.getChildren().add(openItem);
dlg.setVisible(true);
Keyboard Navigation:
author: Joshua J. | MessageBox.java | Class | A MessageBox displays a message (or a component) and allows a
user to respond.
Example:
MessageBox.confirm("resources/ngLF/info.png", "ThinWire",
"Get ready for ThinWire");
Keyboard Navigation:
author: Joshua J. | Panel.java | Class | Panel is a direct implementation of Container .
Example:
TextField tf = new TextField("[Enter Value Here!]");
tf.setBounds(5, 5, 150, 25);
Panel p = new Panel();
p.setBounds(10, 10, 200, 100);
p.getChildren().add(tf);
Frame f = Application.current().getFrame();
f.getChildren().add(p);
author: Joshua J. | ProgressBar.java | Class | A ProgressBar is a screen element that has a visible selection that can be set to any size between zero and a specified length.
ProgressBars are either horizontal or vertical depending on their dimensions. | RadioButton.java | Class | A RadioButton is a screen element that usually appears in groups. | RangeComponent.java | Interface | | Slider.java | Class | A Slider is a screen element that has a cursor that can be set to any position between zero and a specified length.
Sliders are either horizontal or vertical depending on their dimensions. | TabFolder.java | Class | A container for Tab Sheets. | TabSheet.java | Class | A TabSheet is a Panel that can be layered, so that a user can switch between
tab sheets.
Example:
Dialog dlg = new Dialog("TabFolder Test");
dlg.setBounds(25, 25, 600, 400);
TabSheet tSheet1 = new TabSheet("Sheet 1");
TabSheet tSheet2 = new TabSheet("Sheet 2");
TabFolder tFolder = new TabFolder();
tFolder.setBounds(50, 25, 500, 300);
tFolder.getChildren().add(tSheet1);
tFolder.getChildren().add(tSheet2);
TextField tf = new TextField();
tf.setBounds(25, 25, 150, 20);
tSheet2.getChildren().add(tf);
Button firstButton = new Button("Change Tab Title 1");
firstButton.setBounds(50, 50, 150, 30);
firstButton.addActionListener(Button.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent ev) {
((TabSheet) ((Button) ev.getSource()).getParent()).setText("New Title 1");
}
});
tSheet1.getChildren().add(firstButton);
dlg.getChildren().add(tFolder);
dlg.setVisible(true);
Keyboard Navigation:
author: Joshua J. | TextArea.java | Class | This is a multiline text field screen element.
Example:
Dialog dlg = new Dialog();
dlg.setBounds(25, 25, 325, 225);
dlg.setTitle("TextArea Test");
TextArea tArea = new TextArea();
tArea.setBounds(25, 25, 275, 100);
Label lbl = new Label();
lbl.setBounds(25, 150, 275, 30);
lbl.setLabelFor(tArea);
tArea.addPropertyChangeListener(TextArea.PROPERTY_TEXT, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
TextArea source = (TextArea) ev.getSource();
source.getLabel().setText("Text Length (updated when TextArea loses focus): "
+ source.getText().length());
}
});
tArea.setText("Sample text for the TextArea");
dlg.getChildren().add(tArea);
dlg.getChildren().add(lbl);
dlg.setVisible(true);
author: Joshua J. | TextComponent.java | Interface | author: Joshua J. | TextField.java | Class | This is a text field screen element.
Example:
Dialog dlg = new Dialog("TextField Test");
dlg.setBounds(25, 25, 450, 100);
final TextField tf = new TextField();
tf.setBounds(25, 25, 150, 20);
Button btn = new Button("Numeric Mask ###.##");
btn.setBounds(200, 20, 150, 30);
btn.addActionListener(Button.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent ev) {
tf.setEditMask("###.##");
tf.setFocus(true);
}
});
dlg.getChildren().add(tf);
dlg.getChildren().add(btn);
dlg.setVisible(true);
Keyboard Navigation:
- There's no need to set both a maxLength property and an editMask.
- If they conflict - e.g.
| Tree.java | Class | A component that displays a set of hierarchical data as an outline.
Example:
Dialog treeFrame = new Dialog("Tree Test");
treeFrame.setBounds(25, 25, 400, 350);
final Label label = new Label("???????");
label.setBounds(225, 25, 150, 20);
Tree tree = new Tree();
tree.setBounds(10, 10, 200, 300);
Tree.Item root = tree.getRootItem();
root.setText("System Root");
root.setImage(SCORE_IMAGE);
tree.setRootItemVisible(false);
root.setExpanded(false);
Tree.Item readme = new Tree.Item("readme", FILE_IMAGE);
root.getChildren().add(readme);
Tree.Item bill = new Tree.Item("bill", FOLDER_IMAGE);
root.getChildren().add(bill);
Tree.Item startup = new Tree.Item("startup", FILE_IMAGE);
bill.getChildren().add(startup);
Tree.Item billFiles = new Tree.Item("files", FOLDER_IMAGE);
bill.getChildren().add(billFiles);
Tree.Item billFilesAddress = new Tree.Item("Address List", FILE_IMAGE);
billFiles.getChildren().add(billFilesAddress);
Tree.Item billFilesPhone = new Tree.Item("Phone List", FILE_IMAGE);
billFiles.getChildren().add(billFilesPhone);
bill.setExpanded(true);
billFiles.setExpanded(true);
Tree.Item billMusic = new Tree.Item("music", FOLDER_IMAGE);
bill.getChildren().add(billMusic);
Tree.Item billMusicSong1 = new Tree.Item("song1.mp3", FILE_IMAGE);
billMusic.getChildren().add(billMusicSong1);
Tree.Item billPic = new Tree.Item("pictures", FOLDER_IMAGE);
bill.getChildren().add(billPic);
Tree.Item billPicHome = new Tree.Item("home", FOLDER_IMAGE);
billPic.getChildren().add(billPicHome);
Tree.Item billPicS = new Tree.Item("s.jpg", PICTURE_IMAGE);
billPicHome.getChildren().add(billPicS);
Tree.Item billPicP = new Tree.Item("p.jpg", PICTURE_IMAGE);
billPicHome.getChildren().add(billPicP);
Tree.Item billPicM = new Tree.Item("m.jpg", PICTURE_IMAGE);
billPicHome.getChildren().add(billPicM);
Tree.Item jim = new Tree.Item("jim", FOLDER_IMAGE);
root.getChildren().add(jim);
Tree.Item jimStartup = new Tree.Item("startup", FILE_IMAGE);
jim.getChildren().add(jimStartup);
Tree.Item copyright = new Tree.Item("copyright", FILE_IMAGE);
root.getChildren().add(copyright);
tree.addPropertyChangeListener(Tree.Item.PROPERTY_SELECTED, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
label.setText(((Tree.Item) ev.getSource()).getText());
}
});
treeFrame.getChildren().add(tree);
treeFrame.getChildren().add(label);
treeFrame.setVisible(true);
Keyboard Navigation:
KEY |
RESPONSE |
NOTE |
Space |
Fires PropertyChangeEvent( propertyName = Tree.Item.PROPERTY_CHECKED ) |
Only if the component has focus. |
author: Joshua J. | WebBrowser.java | Class | A WebBrowser inserts a web browser object in your application.
Example:
Dialog dlg = new Dialog("WebBrowser Test");
dlg.setBounds(20, 20, 640, 480);
WebBrowser wb = new WebBrowser();
wb.setBounds(25, 25, 590, 430);
wb.setLocation("http://www.thinwire.com");
dlg.getChildren().add(wb);
dlg.setVisible(true);
Keyboard Navigation:
author: Joshua J. | Window.java | Interface | author: Joshua J. |
|