Source Code : Rectangles
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Rectangles

/*--------------------------------------------------
* Rectangles.java
*
* Draw rectangles on a canvas
*
* Example from the book: Core J2ME Technology
* Copyright John W. Muchow http://www.CoreJ2ME.com
* You may use/modify for any non-commercial purpose
*-------------------------------------------------*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class RectanglesMIDlet extends MIDlet
{
private Display display; // The display
private RectangleCanvas canvas; // Canvas
public Rectangles()
{
display = Display.getDisplay(this);
canvas = new RectangleCanvas(this);
}
protected void startApp()
{
display.setCurrent( canvas );
}
protected void pauseApp()
{ }
protected void destroyApp( boolean unconditional )
{ }
public void exitMIDlet()
{
destroyApp(true);
notifyDestroyed();
}
}
/*--------------------------------------------------
* Class RectangleCanvas
*
* Draw arcs
*-------------------------------------------------*/
class RectangleCanvas extends Canvas implements CommandListener
{
private Command cmExit; // Exit midlet
private Rectangles midlet;
public RectangleCanvas(Rectangles midlet)
{
this.midlet = midlet;
// Create exit command & listen for events
cmExit = new Command("Exit", Command.EXIT, 1);
addCommand(cmExit);
setCommandListener(this);
}
/*--------------------------------------------------
* Draw an arc
*-------------------------------------------------*/
protected void paint(Graphics g)
{
g.drawRect(1, 1, 25, 25);
g.drawRoundRect(28, 28, 45, 45, 15, 45);
// g.fillRect(1, 1, 25, 25);
// g.fillRoundRect(28, 28, 45, 45, 15, 45);
}
public void commandAction(Command c, Displayable d)
{
if (c == cmExit)
midlet.exitMIDlet();
}
}
Thank with us