-------
android培训、
java培训、期待与您交流! ----------
GUI编程
GUI指的是Graphics User Interface,即图像化用户接口。通俗的说,就是图形化界面。
JAVA SE中提供了awt包和swing包用于制作图形化界面。
常用的组件:
窗口
Frame
是个容器,用于容纳需要的组件。
Frame f = new Frame();
按钮
Button
按钮的组件
Button b =new Button();
文本框
TextField
单行的文本框
TextField tf = new TextField();
文本域
TextArea
可以理解为多行的文本框
TextArea ta = new TextArea();
菜单栏
MenuBar
菜单栏组件
MenuBar mb = new MenuBar();
菜单
Menu
Menu m = new Menu();
菜单项
MenuItem
菜单中的选项
MenuItem mi = new MenuItem();
组件的使用方法
通过组建调用监听器方法,给组件添加事件,可以实现预想的功能。
一般使用格式:
组件的对象实例.addActionListener(new 各种接口(){
实现接口中的方法。
});