您所在的位置: 首页 > 移动开发 > j2me > j2me基础 >

J2ME UI之窗口部件背景

http://www.j2mehome.com  2009-06-27 08:34  点击:     我要评论()
  • 摘要:主要设计意图是:使窗口跟部件跟活波,可以自己设置背景色等效果. /** * b类名:Background.java/b /br * 编写日期: 2006-8-14 br/ * 程序功能描述:窗口,部件的基本背景类,子类可创建各式各样
  • Tags: 背景 br/ 窗口 int
主要设计意图是:使窗口跟部件跟活波,可以自己设置背景色等效果.
/**
* <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);

【编辑推荐】

  1. MIDP高低级界面开发基础
  2. CLDC系统讲解专题
  3. J2ME的文件系统操作(JSR75)总结
  4. J2ME网络连接框架体系 专家谈J2ME技术
  5. J2ME 记录管理存储RMS介绍
  6. 走进J2ME移动开发世界-j2me入门简介

J2me流媒体技术实现讨论[1]
Android模拟J2ME的JSR75的文件管理开发
J2ME版GIF解码器,支持透明色
手机软件:杀手游戏的法官助手,(人多的时候
J2ME 记录管理存储RMS介绍
loading.. 评论加载中....

频道推荐

更多>>
  • 古堡惊魂-密室

  • 类型:冒险解谜
  • 十五世纪时,罗马尼亚中部特兰西瓦尼亚有一座古堡,名为拜恩古堡。据说,这里住着一位名叫德古拉的伯爵,所以..

推荐博文