马士兵-java第十一章gui笔记_第1页
马士兵-java第十一章gui笔记_第2页
马士兵-java第十一章gui笔记_第3页
马士兵-java第十一章gui笔记_第4页
马士兵-java第十一章gui笔记_第5页
已阅读5页,还剩18页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、window 用ApplicationGUI如窗口 按文由java来实Containerwindow 用ApplicationGUI如窗口 按文由java来实Containercomponent类ComponentContainer1. Frame 是Window String s 创建标题 可Stringimport public class TestFrame public ic void main(String args) FramefnewFrame(String s 创建标题 可Stringimport public class TestFrame public ic void ma

2、in(String args) FramefnewFrame(例二 import public class TestMultiFrame public void main(String args) =class extends sn,Color 例二 import public class TestMultiFrame public void main(String args) =class extends sn,Color 2.LayoutManager import public class TestLayout ic void main(String args) f = new Fram

3、e (frame with p= =f.setLayout(null);/管理器为可以自己设定位p.setLayout(newFlowLayout(FlowLayout.LEFT,11,11);/2.LayoutManager import public class TestLayout ic void main(String args) f = new Frame (frame with p= =f.setLayout(null);/管理器为可以自己设定位p.setLayout(newFlowLayout(FlowLayout.LEFT,11,11);/f.setBounds(0, 0, 4

4、00, 5 例二 用到 BorderLayoutGridLayoutimport public class TenButtons public ic void main(String args) Frame f = new Frame(Java 例二 用到 BorderLayoutGridLayoutimport public class TenButtons public ic void main(String args) Frame f = new Frame(Java f.setLayout(new f.setBounds(100, 100, 400, p1 = nel(new p2 =

5、 nel(new p11 = nel(new p21 = nel(new p1.add(new p1.add(new p11.add(new p11.add(new p2.add(new p2.add(new p1 = nel(new p2 = nel(new p11 = nel(new p21 = nel(new p1.add(new p1.add(new p11.add(new p11.add(new p2.add(new p2.add(new 器注class TestActioneventpublic ic void main(String args) Frame f = new Fra

6、me f.setBounds(200, 200, 200, Button b = new Monitor m = new /new器注class TestActioneventpublic ic void main(String args) Frame f = new Frame f.setBounds(200, 200, 200, Button b = new Monitor m = new /newclass Monitor public void 出System.exit(-class Monitor public void 出System.exit(-class TestActione

7、vent2 public ic void main(String Frame f = new Frame f.setBounds(200, 200, 200, Button b1 new Button b2 new mand(START 会把其名字 Monitor1 m = new class TestActionevent2 public ic void main(String Frame f = new Frame f.setBounds(200, 200, 200, Button b1 new Button b2 new mand(START 会把其名字 Monitor1 m = new

8、 class Monitor1 publicvoidactionPerformed(ActionEvente) game = exit)System.exit(-game = exit)System.exit(-the game START the game the game START the game 6class TsetTextField public ic new class extends TextField zh = 6class TsetTextField public ic new class extends TextField zh = zh.addActionListen

9、er(new TextField mm = new mm.setEchoChar(*);/getEchoChar()mm.addActionListener(new pack();/pack()ewAction public void actionPerformed(ActionEvent e) /getSource() 返最初发生Event 的对象里TextField zh = mm.addActionListener(new pack();/pack()ewAction public void actionPerformed(ActionEvent e) /getSource() 返最初发

10、生Event 的对象里TextField zh = 7.GraphicsGraphics class love7_7foryou public ic void main(String args) new class 7.GraphicsGraphics class love7_7foryou public ic void main(String args) new class Frame public void Label love = new Label(Just for Byframe方法 无需手动调public void Label love = new Label(Just for B

11、yframe方法 无需手动调public void (Graphicsg)/Graphics Color c = g.getColor();/g.fillPolygon(a,b, /window类class TestMouseAdapter public ic void args) new class extends s =new /创立一个容/window类class TestMouseAdapter public ic void args) new class extends s =new /创立一个容Frame2(String this.setBounds(200, 200, 400,

12、this.addMouseListener(new this.addWindowListener(new public void ) public void i = p = Colorcg.getColor();/Frame2(String this.setBounds(200, 200, 400, this.addMouseListener(new this.addWindowListener(new public void ) public void i = p = Colorcg.getColor();/g.fill3DRect(p.x, p.y, 4, 4, g.setColor(c);classMymoniter2extendsWindowAdapter/;类publicvoidwindowClosing(WindowEvent e)class M

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论