Arc MIDlet Example

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

Ads

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

Advertisements

Share on Google+Share on Google+

Arc MIDlet Example

Posted on: December 19, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Arc MIDlet Example  

Post your Comment


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

Ads

 

Ads