c15建立窗口和菜单

c15建立窗口和菜单

ID:36326771

大小:93.50 KB

页数:23页

时间:2019-05-09

c15建立窗口和菜单_第1页
c15建立窗口和菜单_第2页
c15建立窗口和菜单_第3页
c15建立窗口和菜单_第4页
c15建立窗口和菜单_第5页
资源描述:

《c15建立窗口和菜单》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、建立窗口和菜单第十五章回顾异常的定义异常的分类try、catch和finally语句的用法throw、throws子句的用法如何定义自己的异常Java异常机制的优点目标Component类常用方法建立窗口和菜单Component类常用方法Component类是所有组件的父类,其方法为所有组件公共功能的体现。所有组件都继承这些方法。因此,掌握Component类常用方法是很“值得”的。常用方法组件颜色设置组件字体设置组件大小与位置组件激活与可见性组件上的光标paint方法与repaint方法组件颜色设置颜色Color类Color(intr,intg,intb)//r,g,b---[0,255

2、]定义了常用颜色:BLACK、BLUE、CYAN等组件颜色设置publicvoidsetBackground(Colorc)publicColorgetBackground()publicvoidsetForeground(Colorc)publicColorgetForeground()组件字体设置字体Font类publicFont(Stringname,intstyle,intsize)常见样式定义:BOLD、ITALIC等获取计算机上可用字体GraphicsEnvironmenten=GraphicsEnvironment.getLocalGraphicsEnvironment();

3、String[]fontNames=en.getAvailableFontFamilyNames();组件字体设置publicvoidsetFont(Fontf)publicFontgetFont()组件大小与位置2-1常用方法publicvoidsetSize(intwidth,intheight)publicDimensiongetSize()publicvoidsetLocation(intx,inty)publicPointgetLocation()publicvoidsetBounds(intx,inty,intwidth,intheight)publicRectangleget

4、Bounds()组件大小与位置2-2相关类PointpublicPoint(intx,inty)publicdoublegetX()publicdoublegetY()RectanglepublicRectangle(intx,inty,intwidth,intheight)publicdoublegetX()publicdoublegetY()publicdoublegetWidth()publicdoublegetHeight()publicbooleancontains(intx,inty)publicbooleancontains(Rectangler)publicbooleani

5、ntersects(Rectangler)publicRectangleunion(Rectangler)组件激活与可见性激活publicvoidsetEnabled(booleanb)publicbooleanisEnabled()可见性publicvoidsetVisible(booleanb)publicbooleanisVisible()组件上的光标设置光标publicvoidsetCursor(Cursorcursor)publicCursorgetCursor()光标CursorpublicCursor(inttype)publicstaticCursorgetPredefin

6、edCursor(inttype)常见光标类型定义:CROSSHAIR_CURSOR、HAND_CURSOR等等paint方法与repaint方法publicvoidpaint(Graphicsg)可以在子类中重写程序需要显示外观时自动调用publicvoidrepaint()先调用publicvoidupdate(Graphicsg)清除以前画的内容再调用paint(Graphicsg)方法重画建立窗口和菜单Java窗口窗口与屏幕菜单条、菜单、菜单项打印使用剪贴板Java窗口Frame类Container类的间接子类,是容器默认布局为BorderLayoutFrame不能添加到另一个容器

7、中常用方法Frame();Frame(Strings);setTitle(Strings);getTitle();setResizable(booleamb);isResizable();setSize(intwidth,intheight);setBounds(intx,inty,intwidth,intheight);setVisible(booleamb);validate();dispose();窗口与屏幕//获

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。