Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home J2me Arc MIDlet Example

Related Tutorials


 
 

Share on Google+Share on Google+

Arc MIDlet Example

Advertisement
In the previous draw arc example, we have explained how to draw an arch on the screen.

Arc MIDlet Example

     

In the previous draw arc example, we have explained how to draw an arch on the screen. But in this example we are going to show how to draw arc at different locations. To explain it in better way we have described all the methods that used in this application below..

  • g.setColor(255, 162, 117);   
  • g.fillRect(0, 0, width, height);
  • g.setColor(0, 0, 255);   
  • g.fillArc(0, 0, width/2, height/2, 0, 90);   
  • g.setStrokeStyle(Graphics.DOTTED);   
  • g.setColor(0xffff00);   
  • g.drawRect(0, 0, width/2, height/2);
  • g.setStrokeStyle(Graphics.SOLID);   
  • g.setColor(0, 0, 255);   
  • g.fillArc(width/2, 0, width/2, height/2, 0, -90);   
  • g.setStrokeStyle(Graphics.DOTTED);   
  • g.setColor(0xffff00);   
  • g.drawRect(width/2, 0, width/2, height/2); 
  • g.setStrokeStyle(Graphics.SOLID);   
  • g.setColor(0, 0, 255);   
  • g.fillArc(0, height/2, width, height/2, -90, -180);   
  • g.setStrokeStyle(Graphics.DOTTED);   
  • g.setColor(0xffff00);   
  • g.drawRect(0, height/2, width, height/2); 

The Application is as follows:

Source Code of ArcsExample.java

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

public class ArcsExample extends MIDlet{
  private Display display;

  public void startApp(){
  Canvas canvas = new ArcsCanvas();
  display = Display.getDisplay(this);
  display.setCurrent(canvas);
  }

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){}
}

class ArcsCanvas extends Canvas {
  public void paint(Graphics g) {
  int width = getWidth();
  int height = getHeight();

  g.setColor(255162117);
  g.fillRect(00, width, height);

  g.setColor(00255);
  g.fillArc(00, width/2, height/2090);
  g.setStrokeStyle(Graphics.DOTTED);
  g.setColor(0xffff00);
  g.drawRect(00, width/2, height/2);

  g.setStrokeStyle(Graphics.SOLID);
  g.setColor(00255);
  g.fillArc(width/20, width/2, height/20, -90);
  g.setStrokeStyle(Graphics.DOTTED);
  g.setColor(0xffff00);
  g.drawRect(width/20, width/2, height/2);
 
  g.setStrokeStyle(Graphics.SOLID);
  g.setColor(00255);
  g.fillArc(0, height/2, width, height/2, -90, -180);
  g.setStrokeStyle(Graphics.DOTTED);
  g.setColor(0xffff00);
  g.drawRect(0, height/2, width, height/2);  
  }
}

Download Source Code

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 19, 2008

Related Tutorials

Discuss: Arc MIDlet Example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com