📄 rectangular.java
字号:
package com.gameislive.browser.element;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
/**
* 可显示的矩形区域,主要用来显示布局的表格等
*
* @author pan
*
*/
public class Rectangular extends Element{
/**
* 填充色
*/
int color = 0xffffff;
/**
* 边框色
*/
int borderColor = 0xffffff;
Image bgImg;
public Rectangular(int lineId){
super(false,-1,lineId,RECTANGULAR);
}
public void setSize(int w,int h){
this.width = w;
this.height = h;
}
/**
* 设置填充色
* @param color
*/
public void setColor(int color){
this.color = color;
}
boolean showBorder;
/**
* 设置边框色
* @param color
*/
public void setBorderColor(int color){
borderColor = color;
showBorder = true;
}
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public void setBgImage(Image img){
this.bgImg = img;
}
public void draw(int y,int hyperlinks,Graphics g){
// 填充表面
g.setColor(color);
g.fillRect(x,y,width,height);
// 背景图片
if(bgImg!=null){
int w = bgImg.getWidth();
int h = bgImg.getHeight();
for (int i = x; i < width; i += w) {
for (int j = 0; j < height; j += h) {
g.drawImage(bgImg, i, j + y, 20);
}
}
}
// 边框(只有填充色和边框颜色不同时才画,否则没必要)
if(showBorder){
g.setColor(borderColor);
g.drawRect(x, y, width, height);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -