📄 progresscanvas.java
字号:
/*
* @(#)ProgressCanvas 1.0 04/07/01 @(#)
*
* Copyright 2004 NTT DoCoMo, Inc. All rights reserved.
*/
import com.nttdocomo.ui.Canvas;
import com.nttdocomo.ui.Graphics;
/**
* ProgressCanvas<BR>
* The load status screen of the image.
* <br>
* <p>
* @version 1.0
* </p>
*/
public class ProgressCanvas extends Canvas {
/** Maximum of ProgressBar */
private int max = 0;
/** Progress */
private int current = 0;
/** Message */
private String message = null;
/**
* Constructor.
* @param _max Maximum of ProgressBar
*/
public ProgressCanvas(int _max) {
reset(_max);
}
/**
* Initialization
* @param _max Maximum of ProgressBar
*/
public void reset(int _max) {
this.max = _max;
current = 0;
message = "";
}
/**
* Advances
*/
public void add() {
current++;
repaint();
}
/**
* Sets a message.
* @param _message 儊僢僙乕僕
*/
public void setMessage(String _message) {
this.message = _message;
}
/*
* @see com.nttdocomo.ui.Frame#paint(com.nttdocomo.ui.Graphics)
*/
public void paint(Graphics g) {
int width = this.getWidth() - 10;
g.lock();
g.setColor(Color.BLACK);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(Color.WHITE);
g.drawString(this.message, 5, this.getHeight() / 2 - 15);
g.setColor(Color.GRAY);
g.fillRect(5, this.getHeight() / 2 - 10, width, 20);
g.setColor(Color.BLUE);
g.fillRect(5, this.getHeight() / 2 - 10, width * current / max, 20);
g.unlock(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -