displayable1.java~1~

来自「自己没事的时候画的图形」· JAVA~1~ 代码 · 共 48 行

JAVA~1~
48
字号

import javax.microedition.lcdui.*;

public class Displayable1 extends Canvas implements CommandListener {
  /** Constructor */
  public Displayable1() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  /**Component initialization*/
  private void jbInit() throws Exception {
    // Set up this Displayable to listen to command events
    setCommandListener(this);
    // add the Exit command
    addCommand(new Command("Exit", Command.EXIT, 1));
  }

  /**Handle command events*/
  public void commandAction(Command command, Displayable displayable) {
    /** @todo Add command handling code */
    if (command.getCommandType() == Command.EXIT) {
// stop the MIDlet
      MIDlet1.quitApp();
    }
  }

  /** Required paint implementation */
  protected void paint(Graphics g) {
    int width = getWidth();
    int height = getHeight();
// Fill the background using black
    g.setColor(0);
    g.fillRect(0, 0, width, height);
    g.setColor(0xFFFFF00);
    g.drawRect(width/4,height/3,width/2,height/4);
    g.drawArc(width/4,height/8,width/2,height/5,0,360);
    g.drawArc(0,0,width/2,height/4,90,-90);
    g.drawArc(width/2,0,width/2,height/4,90,90);
    g.drawArc(width/8,height/6,width/8,height/8,0,360);
    g.drawArc(6*width/8,height/6,width/8,height/8,0,360);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?