📄 waitcanvas.java
字号:
/*
* Created on 2004-3-14
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package com.north.phonebook.ui;
import java.util.*;
import javax.microedition.lcdui.*;
/**
* @author J2me Group
*
* To change the template for this generated type comment go to Window -
* Preferences - Java - Code Generation - Code and Comments
*/
public class WaitCanvas extends Canvas
{
private int mCount, mMaximum;
private int mInterval;
private int mWidth, mHeight, mX, mY, mRadius;
private String mMessage;
private boolean run = false;
public WaitCanvas(String message, boolean run)
{
this.mMessage = message;
mCount = 0;
mMaximum = 36;
mInterval = 100;
mWidth = getWidth();
mHeight = getHeight();
// Calculate the radius.
int halfWidth = (mWidth - mRadius) / 2;
int halfHeight = (mHeight - mRadius) / 2;
mRadius = Math.min(halfWidth, halfHeight);
// Calculate the location.
mX = halfWidth - mRadius / 2;
mY = halfHeight - mRadius / 2;
// Create a Timer to update the display.
if (run)
{
TimerTask task = new TimerTask()
{
public void run()
{
mCount = (mCount + 1) % mMaximum;
repaint();
}
};
Timer timer = new Timer();
timer.schedule(task, 0, mInterval);
}
}
/**
* @param message The mMessage to set.
*/
public void setMMessage(String message)
{
mMessage = message;
}
public void paint(Graphics g)
{
int theta = -(mCount * 360 / mMaximum);
// Clear the whole screen.
g.setColor(255, 255, 255);
g.fillRect(0, 0, mWidth, mHeight);
// Now draw the pinwheel.
g.setColor(128, 128, 255);
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);
// Draw the message, if there is a message.
if (mMessage != null)
{
g.drawString(mMessage, mWidth / 2, mHeight, Graphics.BOTTOM
| Graphics.HCENTER);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -