图形用户界面_第1页
图形用户界面_第2页
图形用户界面_第3页
全文预览已结束

下载本文档

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

文档简介

1、抽象窗口工具()简介1. 基本窗口类:Frame,Dialog2. 基本GUI构类:button,label,textField,TextArea,checkbox3. 基本事件类:ActionEvent,InputEvent,ItemEvent,KeyEvent,MouseEvent,WindowEvent4. 基本事件监听接口:ActionListener.windowListener,MouseListener,keyListener5. 基本布局控制:FlowLayout,BorderLayout,GridLayout,Panel6. 基本画图支持:Graphics,CanvasFra

2、me类Awt对Frame类的定义Public class Frame extends Window implements Container public Frame() public Frame(String title) public String getTitle() public void setTitle(String title) public MenuBar getMenuBar() public void setMenuBar(MenuBar mb) public void dispose()Window 类Public class Window extends Contain

3、er public Window(Frame parent) Public void Pack() Public void setVisiable(Boolean b) Public void toFront() Public void toBack() Public void addWindowListener(WindowListener l) Public void removeWindowListener(WindowListener l)Container类Container 的子类有:window,frame,panel,applet类Public abstract class C

4、ontainer extends Component Protected Container() Public void add(Component comp) Public void add(Component comp,Object constraints) Public Insets getInsets() Public void setLayout(LayoutManager mgr) Public void validate() Public Dimension getPreferredSize() Public void paint(Graphics g)Panel类Dialog类

5、2、简单的GUI构件类Button类构造方法有:Public Button()Public Button(String label)常用方法有:Public String getLabel() 获取按钮上的字符串Public void setLabel(String label) 重新设置按钮上的字符串Public void addActionListener(ActionListener l)Public void removeActionListener(ActionListener L)TextField类构造方法的定义为:Public TextField()Public TextFie

6、ld(String text)Public TextField(int colums)Public TextField(String text,intcolums)文本域中的两个重要方法:Public void addActionListener(ActionListener l)Public void removeActionlistener(actionListener)Lable类构造方法:Public label()Public label(String text)Public label(String text,int alignment)常用方法:Public string get

7、text()Public void setText(String text()TextArea类定义:Public class TextArea extends TextComponent public textarea()Public textarea(String text)Public textArea(int rows,int columns)Public textarea(string text,int rows,int columns)Public void append(String str)Public void insert(String str,int pos)Public

8、 void replaceRange(string str,int start ,int end)_事件源:事件源(Event source)是指一个产生事件的对象,这是因为该对象的内部状态改变而造成的。事件源可以有一个或多个事件。基本的事件有:EventObject 是所有事件的基础类,它包含于java.util包中。EventObject含有getSource()与toString()两个方法,getSource()方法传回事件源,toString()方法则传回表示该事件的字符串AWTEvent是EventObject的衍生类,同时也是所有AWT类型事件的基础类,它包含于java.util

9、包中。AWTEvent类的getID()方法可用来获取事件的类型ActionEvent类时鼠标点击按钮、选择功能表list的功能项,双击菜单项的选择项、或文本域中按键盘的Enter键,将产生的事件AdjustmentEvent是滑杆scrollbar移动是产生的事件Component 是当一个构件component 被移动、改变大小、隐藏或显现时将产生的事件FocusEvent是一个构件取得或失去控制权focus时将产生的事件InputEvent是keyEvent与MouseEvent的上一层基础类ItemEvent是当选择下列表choise,列表list的选择项、或多选框checkbox时产

10、生的事件KeyEvent是按下pressed且或放开release键盘按键时将产生的事件。MouseEvent是点击clicked、移动moved、或拖曳draged鼠标按键时将产生的事件TextEvent是改变文本域TextField或文本区TextArea的内容时将产生的事件TextSelectionEvent是选择文本域TextField或文本区TextArea的文字时将产生的事件最常见的事件类型及其获取事件属性方法事件类型事件处理方法ActioneventInputeeventItemeventKeyeventMouseeventWindowevent getActionCommand

11、()isShiftDown()、isControlDown()、isAltDown()、getWhen()、public void consue()getItem()、getStateChange()getkeycode(),getKeychar()getx(),gety(),getpoint(),getclickcount()getwindow()事件监听接口及其抽象方法接口包含的方法ActionlistenerActionperformedItemlistenerItemstatechangedWindowlistenerWindowclosing,windowopened,windowiconied,windowdeicomined,Windowclosed,windowactivated,windowdeactivatedMousemotionl

温馨提示

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

评论

0/150

提交评论