CIS525 - Lecture#18 - November 6, 2000
CIS 525 11/6/00
Dilbert-n-data mining!
Chap. 13, GUI controls and Java
buttons:
- declare instances
- use contruction label
- add buttons to container object
see Buttons.java/Buttons.html page 650
images on top of buttons, see 657-
Checkboxes, page 669:
- independent of one another
strategy:
-create an instance and add it to container
handling:
1) watch for an action event, (1.02)
2) watch for an item selection event, (1.1)
3) use getState to lokup value when needed
enable events, (in 1.1) page 672
enableEvents(AWTEvent.ITEM_EVENT_MASK);
see Checkboxes.java, page 670
radio buttons in Java, page 673, CheckboxGroup()
CheckboxGroup cbGroup = new CheckboxGroup();
Checkbox cb1 = new Checkbox("...", cbGroup, true);
add(cb1);
see CheckboxGroups.java page 674
in 1.02
getCurrent() to get selected box
in 1.1
getSelectedBox() to get selected box
Choice menu, (pull-down); page 677
strategy
1) create empty menu;
Choice choice = new Choice();
2) add items
Choice.addItem("..."); 1.02
Choice.add("..."); 1.1
3) add menu to container
see ChoiceTest.java page 681
List boxes, page 682
scrolling selection lists
see Lists.java, (standalone), page 683
new List(3, true); multiple select
new List(3, false); single select
2 possible events:
1) selection event
2) action event
see SelectionReporter.java and ListEvents3.java page 693
Text field, page 695
- boxes, read or write, (single line of text), no mixed fonts or colors
input field
TextField lastNameField = new TextField(15); //default length
add(lastNameField);
output field
TextField tempField = new TextField("Java");
tempField setEditable(false);
1) focus (gotFocus, listFocus)
2) keyboard, (keyDown, keyUp)
3) action
see JavaTextField.java page 702
text fields events in Java 1.1;
1) focus events
2) keyboard events
3) text events, setText() from inside program
4) action events, user enters text
see LanguageField.java page 705
text areas, page 707
- multiple lines
- no action events
- with or without scrollbars
TextArea inputArea = new TextArea(4,15);
see TextAreas.java page 709
scroll bars, labels, etc