05 Java AWT Programming
05 Java AWT Programming
605.741
David Silberberg
Overview
setLayout(new BorderLayout());
this.add("North", button1);
this.add("East", button2);
this.add("South", button3);
this.add("West", button4);
this.add("Center", button5);
this.remove(button1);
…
this.removeAll();
D. Silberberg Distributed Database Systesm Java 5
AWT Programming
GridLayout
TextField field1 = new TextField();
TextField field2 = new TextField(30);
TextField field3 = new TextField("Init string");
TextField field4 = new TextField("Init string", 30);
add(field1);
…
OR
String[] itemList = list.getSelectedItems();
TextArea.SCROLLBARS_BOTH
TextArea.SCROLLBARS_VERTICAL_ONLY
TextArea.SCROLLBARS_HORIZONTAL_ONLY
TextArea.SCROLLBARS_NEITHER
Checkbox cb = cbg.getCurrent();
Checkbox cb = cbg.selectedCheckbox();
cbg.setCurrent(cb);
import java.awt.*;
import java.awt.event.*;
// variables defined
}
}
if (command.equals("Select")) {
…
}
// or
if (button == getSource()) {
…
}
…
}
}
D. Silberberg Distributed Database Systesm Java 16
AWT Programming
Button Listener (cont.)
• In calling code: