Home J2me Graphics MIDlet Example



Graphics MIDlet Example
Posted on: December 11, 2008 at 12:00 AM
This is the another graphic example, where we are going to draw a image that look and act like satellite and earth.

Graphics MIDlet Example

     

This is the another graphic example, where we are going to draw a image that look and act like satellite and earth. For creating these types of graphics in J2ME we use MIDlet's. In the example we have created PacerCanvas class that extends the canvas class  to draw this graphics.

Please find the methods that are used in this example..

  • getWidth();  
  • getHeight();  
  • setColor(255162117);  
  • fillRect(00, w, h);  
  • setColor(00255);  
  • drawLine(0, w - x, x, 0);  
  • drawRect(z, z, 3030);  
  • fillRoundRect(z, z, 30301010);  
  • drawArc(z, z, 30300360);

The Application is as follows:

Source Code of PacerExample.java

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class PacerExample 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(255162117);
  g.fillRect(00, w, h);
  g.setColor(00255);

  for(int x = 0; x < w; x += 20){
  g.drawLine(0, w - x, x, 0);
  }
  int z = 100;
  g.drawRect(z, z, 3030);
  z += 20;
  g.fillRoundRect(z, z, 30301010);
  z += 20;
  g.drawArc(z, z, 30300360);
  

Download Source Code

Related Tags for Graphics MIDlet Example:
cimagegraphthisoolikeexamplewheretodrawexamraweareitnotliimartinnomsatelliteageearthxaxampsatkishallmplgographiceaandaractrtsassthaphatmagepleplndo


More Tutorials from this section

Ask Questions?    Discuss: Graphics MIDlet Example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.