Java Component类的常用方法
来源:互联网 发布:js 工作流引擎 编辑:程序博客网 时间:2024/05/20 03:47
一、组件的颜色
1.public void setBackground(Color c);
2.public void setForeground(Color c);
3.public Color getBackground(Color c); //获取组件的背景色
4.public Color getForeGround(Color c); //获取组件的前景色
Color类是Java.awt包中的类。用Color类的构造方法public Color(int red,int green,int blue)可以创建一个颜色对象,三个颜色值取值都在0-255之间。Color类还有red,blue,green,orange,cyan,yellow,pink等静态常量。
二、组件的字体
1.public void setFont(Font f);
2.public Font getFont(Font f);
3.public Font(String name,int style,int size);
1) name:字体名称,如果系统中无该字体,则取默认的字体名字。
2) style:字体的式样,取值是一个整数,其有效取值为:
Font.BOLD,Font.PLAIN,Font.ITALIC,
Font.ROMAN_BASELINE,Font_CENTER_BASELINE,Font.HANGING_BASELINE,
FOnt.TRUETYPE_FONT
3) size:字体的大小,单位是磅(如5号字体是12磅)。
4.获取系统中有哪些字体名字可用的方法:
GraphicsEnvironment ge=GraphicsEnvironment getLocalGrphicsEnvironme
String fontName[]=ge.getAvailableFontFamilyNa
三、组件的大小与位置
1.public void setSize(int width,int height);
2.public void setLocation(int x,int y);
3.public Dimension getSize();
4.public Point getLocation(int x,int y);
5.public void setBounds(int x,int y,int width,int height);
6.public Rectangle getBounds();
Rectangle对象的常用方法:
1) Rectangle(int x,int y,int width,int height);
2) public boolean intersects(Rectangle rect);
3) public boolean contains(int x,int y);
4) public boolean contains(int x,int y,int width,int height);//矩形是否包含参数指定的矩形
5) public boolean contains(Rectangle rect); //同上
6) public Rectangle intersection(Rectangle rect);
7) public Rectangle union(Rectangle rect);
四、组件的激活与可见性
1.public void setEnabled(boolean b);
2.public boolean isEnabled();
3.public void setCisible(boolean b);
4.public boolean isVisible();
五、组件上的光标
1.public void setCursor(Cursor c);
2.Cursor c=new Cursor(Cursor.HAND_CURSOR);
3.Cursor c=Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); //直接获得一个光标对象
六、paint方法与repaint方法
public void paint(Graphics g);
repaint方法首先清除paint方法所画内容,然后再调用paint方法。
- Java Component类的常用方法
- JAVA中常用类的常用方法
- JAVA中常用类的常用方法
- java 常用数学方法 Math常用方法 必须掌握--Java的常用类
- Java常用的类——String的常用方法
- Java中Math类的常用方法
- java数学类Math的常用方法
- Java中Math类的常用方法
- Java中Math类的常用方法
- (java)中file类的常用方法
- Java属性类:Properties的常用方法
- Java中常用的类以及方法
- JAVA String类的常用方法总结
- Java中的一些常用类的方法
- java中String类的常用方法
- Java中Math类的常用方法
- Java中Math类的常用方法
- Java:String类的常用方法
- javascript伪数组参数
- 黑马程序员_java基础二(线程和集合)
- c# 动态产生控件 注册动态控件事件
- JQuery中一个简单的表单验证的实例
- android tombstone
- Java Component类的常用方法
- arcgis for android 短路径分析 查找最短路径
- 写在大三将要结束之际
- 短信发送
- 你不了解PHP的10件事情
- oracle latch详解
- java io
- 看你有什么需要
- Python:迭代器