黑马程序员—GUI
来源:互联网 发布:wang域名可以备案吗 编辑:程序博客网 时间:2024/05/16 12:42
GUI:Graphical User Interface 图形用户接口
CLI:Command Uesr Interface 命令行用户接口,比如常见的Dos命令行操作
AWT:Abstract Window ToolKit 抽象窗口工具包
Swing:在AWT的基础上建立的一套图形界面系统
GUI继承关系图
- package Base;
- import java.awt.Button;
- import java.awt.FlowLayout;
- import java.awt.Frame;
- import java.awt.TextArea;
- import java.awt.TextField;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowAdapter;
- import java.awt.event.WindowEvent;
- public class MyWindowDemo
- {
- //定义成员变量
- private Frame f;//窗口
- private TextField tf;//文本行
- private Button zhuandaoButton,exitButton;//按钮
- private TextArea ta;//文本区域
- MyWindowDemo()
- {
- init();
- }
- public void init()
- {
- //顶一个窗口
- f = new Frame("my window");
- //对frame进行基本设置
- //长宽高低
- f.setBounds(300,100,500,300);
- //设置布局管理器
- f.setLayout(new FlowLayout());
- tf=new TextField(50);
- zhuandaoButton = new Button("转到");
- exitButton = new Button("退出");
- ta = new TextArea(10,60);
- //将组建添加到f中
- f.add(tf);
- f.add(zhuandaoButton);
- f.add(exitButton);
- f.add(ta);
- //加载窗体上的事件
- myEvent();
- //显示窗体
- f.setVisible(true);
- }
- private void myEvent()
- {
- //定义事件,点击exitButton,就退出
- exitButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- System.exit(0);
- }
- });
- //点击zhuandaoButton按钮,就会将文本行中的数据添加到文本区域中
- zhuandaoButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- //tf.getText("");
- String text = tf.getText();
- //System.out.println(text);
- ta.append(text);
- ta.append("");
- }
- });
- //关闭事件
- f.addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- System.exit(0);
- }
- });
- }
- public static void main(String[] args)
- {
- new MyWindowDemo();
- }
- /*public static void showFrame()
- {
- Frame f = new Frame("对话框");
- f.setBounds(300,200,500,300);
- f.setLayout(new FlowLayout());
- Dialog d = new Dialog(f,true);
- Button button = new Button("转到");
- f.add(d);
- f.add(button);
- f.setVisible(true);
- }
- */
- }
0 0
- 黑马程序员—GUI
- 黑马程序员—GUI
- 黑马程序员 — GUI
- 黑马程序员—GUI
- 黑马程序员—GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 黑马程序员——GUI
- 【ExtJS 4.x学习教程】(3)布局和容器(Layouts and Containers)
- 如何在SharePoint中配置和自定义Content Query Web Part(一)
- 【map+审题】#19 A. World Football Cup
- Linux进程间通信-消息队列
- Android GridView 添加 网格线解决办法
- 黑马程序员—GUI
- asp.net mvc 导出excel
- 问:jmm,你们喜欢在网上买什么啊?
- Java 的 super 学习的一个实例
- 如何使用ubuntu的启动U盘修复grub
- java读写 文档
- UCT(信心上限树算法)解四子棋问题——蒙特卡罗法模拟人机博弈
- 《Javascript权威指南》学习笔记之十:ECMAScript 5 增强的对象模型
- UVa 10591 - Happy Number