⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gaugealert.java

📁 是一款飞行射击游戏
💻 JAVA
字号:
//GaugeAlert.java file
package itemex;
import javax.microedition.lcdui.*;

public class GaugeAlert extends Alert
{//Button 类,用于表示按钮
    private Gauge gauge;
    private int updatePeriod;

    //构造函数:title:标题,timeout:自动消失超时时间,以毫秒计算
    public GaugeAlert(String title, int timeout)
    {
        super(title, null, null, null);
        //设置超时自动消失的时间
        setTimeout(timeout);
        //创建进度条并把进度条添加到警告窗口中
        gauge = createIndicator(getTimeout());
        setIndicator(gauge);
    }
    //构造函数
    //参数title:标题,alertType:警告类型,alertImage:图标
    //alertType:警告类型,timeout:自动消失超时时间
    public GaugeAlert(String title, String alertText, Image alertImage, AlertType alertType, int timeout) 
    {
        super(title, alertText, alertImage, alertType);
        //设置超时自动消失的时间
        setTimeout(timeout);
        //创建进度条并把进度条添加到警告窗口中
        gauge = createIndicator(getTimeout());
        setIndicator(gauge);
    }
    //创建进度条
    private Gauge createIndicator(int maxValue) 
    {      if (maxValue == Alert.FOREVER) 
        {//如果警告窗口不是自动消失的,则创建一个运行状态的进度条,不使用线程            return new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);        }     final int max= maxValue/1000;
        final Gauge indicator = new Gauge(null, false, max, 0);       new Thread() 
        {//创建一个定时更新进度的线程          public void run() 
            {              	int value = 0;             	while (value < max) 
                {//每次将当前进度增加一                    indicator.setValue(value);                    ++value;                    try 
                    {                      Thread.sleep(1000);                    }
                    catch (InterruptedException ie) { }                }            }
        }.start();     return indicator;    }    
}
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -