第十二章 GUI组件
第十二章 GUI组件
第十二章 GUI组件
1
2006-12-6
学习内容
学习内容
常用AWT组件介绍
菜 单(Menu)
控制外观
2
2006-12-6
第一节 常用AWT组件介绍
第一节 常用AWT组件介绍
AWT组件的特点:
–AWT组件提供了控制界面外观,包括颜色
和字体的机制
–AWT还支持打印 (这是在JDK1.1版中引入
的)
3
2006-12-6
按钮 (Button)
按钮 (Button)
public class SampleButton implements ActionListener {
b = new Button(Sample);
b.addActionListener(this);
public void actionPerformed( ActionEvent ae) {
System.out.println(Button press received.);
System.out.println(Buttons action command is: +
ae.getActionCommand());
}
4
2006-12-6
复选框(Checkbox)
复选框(Checkbox)
Checkbox组件提供一种简单的“开/
关”输入设备,它旁边有一个文本标
签。
Frame f = new Frame(Checkbox)
Checkbox one = new Checkbox(One, true);
Checkbox two = new Checkbox(Two, false);
Checkbox three = new Checkbox(Three, true);
one.addItemListener(this);
two.addItemListener(this);
three.addItemListener(this);
f.add(one);
f.add(two);
f.add(three);
5
2006-12-6
复选框组-单选框(Checkbox
复选框组-单选框(Checkbox
group-Radio Button)
group-Radio Button)
Frame f = new Frame(Checkbox Group);
CheckboxGroup cbg = new CheckboxGroup();
Checkbox one = new Checkbox(One, false, cbg);
Checkbox two = new Checkbox(Two, false, cbg);
原创力文档

文档评论(0)