Download J2ME WheelItem CustomItem
October 6th, 2007 Posted in J2ME / JavaME
This is an example of J2ME / JavaME CustomItem called WheelItem. It does nothing beside showing a spinning wheel on the phone screen. WheelItem is a perfect candidate to be displayed on a wait form screen replacing Gauge class while your application is performing lengthy operating.
WheelItem Screenshot
JAVA:
-
import javax.microedition.midlet.*;
-
import javax.microedition.lcdui.*;
-
import java.util.*;
-
-
public class WheelItem extends CustomItem
-
{
-
private int mCount,mMaximum;
-
private int mInterval;
-
private int mWidth,mHeight,mX,mY,mRadius;
-
private String mMessage;
-
-
{
-
super(title);
-
mCount=0;
-
mMaximum = 36;
-
mInterval = 100;
-
-
public void run() {
-
mCount = (mCount+1) % mMaximum;
-
repaint();
-
}
-
};
-
timer.schedule(task,0,mInterval);
-
}
-
{
-
mMessage = string;
-
repaint();
-
}
-
-
mWidth = iWidth;
-
mHeight = iHeight;
-
int halfWidth = mWidth/2;
-
int halfHeight = mHeight/2;
-
-
mX = halfWidth - mRadius/2;
-
mY = halfHeight - mRadius/2;
-
-
int theta = -(mCount*360/mMaximum);
-
-
g.setColor(255,255,255);
-
g.fillRect(0,0,mWidth,mHeight);
-
g.setColor(0,0,0);
-
g.drawArc(mX,mY,mRadius,mRadius,0,360);
-
g.fillArc(mX,mY,mRadius,mRadius,theta+90,90);
-
g.fillArc(mX,mY,mRadius,mRadius,theta+270,90);
-
-
if (mMessage !=null)
-
{
-
}
-
}
-
public int getMinContentWidth() { return 80; }
-
public int getMinContentHeight() { return 80; }
-
public int getPrefContentWidth(int width) {return getMinContentWidth();}
-
public int getPrefContentHeight(int height) {return getMinContentHeight();}
-
}
Download example application with WheelItem source : WaitFormDemo.zip
Ported (rather poorly) from Wheel canvas written by Jonathan Knudsen from his article - Networking, User Experiences and Threads.
Any suggestions or improvements are welcomed!
April 19th, 2009 at 7:52 pm
Download example application with WheelItem source : WaitFormDemo.zip
——————-
page not found !!