Fill Round Rectangle : Rectangle « J2ME « Java Tutorial






Fill Round Rectangle
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;

public class J2MEPacer extends MIDlet {
  public void startApp() {
    Displayable d = new PacerCanvas();

    d.addCommand(new Command("Exit", Command.EXIT, 0));
    d.setCommandListener(new CommandListener() {
      public void commandAction(Command c, Displayable s) {
        notifyDestroyed();
      }
    });

    Display.getDisplay(this).setCurrent(d);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }
}

class PacerCanvas extends Canvas {
  public void paint(Graphics g) {
    int w = getWidth();
    int h = getHeight();

    g.setColor(0xffffff);
    g.fillRect(0, 0, w, h);
    g.setColor(0x000000);

    g.drawRect(12, 12, 20, 20);
    g.fillRoundRect(33, 33, 20, 20, 5, 5);
    g.drawArc(8, 88, 20, 20, 0, 360);
  }
}








31.33.Rectangle
31.33.1.Fill rectangleFill rectangle
31.33.2.Draw rectangleDraw rectangle
31.33.3.Fill Round RectangleFill Round Rectangle
31.33.4.Fill a rectangle, and a round rectangleFill a rectangle, and a round rectangle