没有合适的资源?快使用搜索试试~ 我知道了~
java教程(第十一章GUI).doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 65 浏览量
2022-06-10
06:11:22
上传
评论
收藏 421KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/85597397/0001-0cdfb2f233fbd9cb80418acf3e9dea31_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
15页
java教程(第十一章GUI)
资源推荐
资源详情
资源评论
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/release/download_crawler_static/85597397/bg1.jpg)
十一节:GUI
★AWT(abstract window toolkit)包括了很多类和接口,用
于 java Application 的 GUI 编程
★GUI 的各种元素(如窗口,按钮,文本)由 java 来实现
★使用 AWT 所涉及的类一般在 java.awt 包及其子包中
★Container 和 component 是 AWT 中的两个核心类
Component 和 Container 区别:
![](https://csdnimg.cn/release/download_crawler_static/85597397/bg2.jpg)
1. Frame
★Frame 是 Window 的子类,由 Frame 或其子类创建的对象作为一
个窗体。
★Frame 的常用构造方法:
●Frame()
●Frame(String s)创建标题,所以在创建类继承它时,可
以用 super(String name)来创建标题
例一:
import java.awt.*;
public class TestFrame {
public static void main(String[] args) {
Frame f = new Frame("聊天室");//给出名字
f.setLocation(300,300);
f.setSize(500,200);
f.setResizable(true);
f.setBackground(Color.white);
f.setVisible(true);
}
}
结果:
![](https://csdnimg.cn/release/download_crawler_static/85597397/bg3.jpg)
例二:使用新类继承,注意用 super 来给出名字
import java.awt.*;
public class TestMultiFrame {
public static void main(String[] args) {
MyFrame m1 = new MyFrame(0,0,100,100,Color.red);
MyFrame m2 = new MyFrame(130,110,100,100,Color.blue);
MyFrame m3 = new MyFrame(0,110,100,100,Color.green);
MyFrame m4 = new MyFrame(130,0,100,100,Color.yellow);
}
}
class MyFrame extends Frame{
static int id;
MyFrame(int x,int y,int m,int n,Color c){
super("Myframe"+(++id));//super起名
setLocation(x,y);
setSize(m,n);
setBackground(c);
setVisible(true);
setLayout(null);
}
}
结果:
剩余14页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
omyligaga
- 粉丝: 54
- 资源: 2万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)