📄 drawgrbcanvas.java
字号:
package DrawGRB;import javax.microedition.lcdui.*;import javax.microedition.midlet.*;import java.io.*;public class DrawGRBCanvas extends Canvas{ private int[] pixelArray; public DrawGRBCanvas() { } public void paint(Graphics g) { g.setColor(0xFFFF00); g.fillRect(0, 0, this.getWidth(), this.getHeight()); int x = 0, y = 0; // Where on the display to draw the image int width = 35, height = 35; // Size of the image // Define the array for image if(pixelArray == null) pixelArray = new int[width * height]; // Create a fully opaque image, specifying only a value for red for(int i = 0; i < pixelArray.length; i++) pixelArray[i] = 0xffff0000; g.drawRGB(pixelArray, 0, width, x, y, width, height, false); g.drawRect(x, y, width, height); // Box the rectangle // Create a “half” opaque image, specifying only a value for red x = 35; y = 35; for(int i = 0; i < pixelArray.length; i++) pixelArray[i] = 0x7fff0000; g.drawRGB(pixelArray, 0, width, x, y, width, height, true); g.drawRect(x, y, width, height); // Box the rectangle x = 70; y = 70; // Create a fully transparent image, specifying only a value for red for(int i = 0; i < pixelArray.length; i++) pixelArray[i] = 0x00ff0000; g.drawRGB(pixelArray, 0, width, x, y, width, height, true); g.drawRect(x, y, width, height); // Box the rectangle }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -