主要设计意图是:使窗口跟部件跟活波,可以自己设置背景色等效果.
/**
* <b>类名:Background.java</b> </br>
* 编写日期: 2006-8-14 <br/>
* 程序功能描述:窗口,部件的基本背景类,子类可创建各式各样的背景,图片背景,半透明背景<br/>
* Demo: <br/>
* Bug: <br/>
*
* 程序变更日期 :<br/>
* 变更作者 :<br/>
* 变更说明 :<br/>
*
* @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
*/
public abstract class Background {
/**
* Defines the width of this Background.
* Usually this is 0, but some backgrounds might have a border included.
*/
protected int borderWidth;
protected int borderColor;
protected int backgroundColor;
/**
* Creates a new Background.
* The width of this background is set to 0 here.
*/
public Background() {
this.borderWidth = 0;
this.borderColor = 0;
this.backgroundColor = 0x7899999; //灰色
}
/**
* Paints this background.
*
* @param x the horizontal start point
* @param y the vertical start point
* @param width the width of the background
* @param height the height of the background
* @param g the Graphics on which the background should be painted.
*/
public abstract void paint( int x, int y, int width, int height, Graphics g );
}
/**
* <b>类名:LucencyBackground.java</b> </br> 编写日期: 2006-8-14 <br/> 程序功能描述:
* 创建具有透明度的背景<br/> Demo: <br/> Bug: <br/>
*
* 程序变更日期 :<br/> 变更作者:<br/> 变更说明 :<br/>
*
* @author wuhua </br> <a href="mailto:rrq12345@163.com">rrq12345@163.com</a>
*/
public class LucencyBackground extends Background {
// 透明图片
private Image lucencyImage;
// 透明度
private int alpha ;
/**
* 设置背景色,跟透明度创建一个具体透明效果的背景
* @param _backgroundColor
* @param _alpha
*/
public LucencyBackground(int _backgroundColor, int _alpha ) {
backgroundColor = _backgroundColor;
alpha = _alpha ;
}
public void paint(int x, int y, int width, int height, Graphics g) {
initLucencyImage(width, height);
paint(x, y, g);
}
/*
* 初始话背景图片
*/
private void initLucencyImage(int width, int height) {
// 创建一个指定高,宽的可修改图片
lucencyImage = Image.createImage(width, height);
【编辑推荐】
- MIDP高低级界面开发基础
- CLDC系统讲解专题
- J2ME的文件系统操作(JSR75)总结
- J2ME网络连接框架体系 专家谈J2ME技术
- J2ME 记录管理存储RMS介绍
- 走进J2ME移动开发世界-j2me入门简介