AWT Controls
Site Admin
· 11 Sep 2026
· 2 views
Basic Controls
AWT ships practical input controls that all extend Component:
- Label - static text.
- TextField - one-line input.
- Button - clickable action.
- Checkbox and CheckboxGroup - toggles and radio groups.
- TextArea - multi-line text.
- Panel - a container to group controls.
Code
Label name = new Label("Name:");
TextField field = new TextField(15);
Button go = new Button("Submit");
Checkbox agree = new Checkbox("I agree");
TextArea notes = new TextArea(4, 25);
Panel p = new Panel();
p.setLayout(new FlowLayout());
p.add(name); p.add(field); p.add(go);
add(p);
add(agree);
add(notes);





Key Points
- Use TextField for single-line and TextArea for multi-line input.
- CheckboxGroup makes mutually exclusive radio buttons.
- Panels group related controls and get their own layout manager.