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

📄 alert.java

📁 J2me唆哈的代码
💻 JAVA
字号:
/*
 * Created on 2005-8-18 by pcy
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package javax.microedition.lcdui;

import a.a.a.b.Resource;
import a.a.a.midp.lcdui.*;

/**
 * @author pcy
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Alert extends Screen {

    public static final int FOREVER=-2;
    
    public final static Command DISMISS_COMMAND = new Command(Resource.getString("Done"), Command.OK, 0);

    public Alert(String title){
        this(title, null, null, null);
    }
    
    public Alert(String title,
                 String alertText,
                 Image alertImage,
                 AlertType alertType){
        synchronized (Display.LCDUILock) {
            instance=new BQAlert(title,alertText, 
                    alertImage==null?null:alertImage.getBQImage(),
                    alertType==null?null:alertType.getBQAlertType());
            instance.setShell(this);
        }
    }
    
    public int getDefaultTimeout(){
        synchronized (Display.LCDUILock) {
            return ((BQAlert)instance).getDefaultTimeout();
        }
    }
    
    public int getTimeout(){
        synchronized (Display.LCDUILock) {
            return ((BQAlert)instance).getTimeout();
        }
    }
    
    public void setTimeout(int time){

        synchronized (Display.LCDUILock) {
            ((BQAlert)instance).setTimeout(time);
        }
    }
    
    public AlertType getType(){
        
        return ((BQAlert)instance).getType().getShell();
    }
    
    public void setType(AlertType type){
        synchronized (Display.LCDUILock) {
            ((BQAlert)instance).setType(type.getBQAlertType());
        }
    }
    
    public String getString(){
        return ((BQAlert)instance).getString();
    }
    
    public void setString(String str){
        synchronized (Display.LCDUILock) {
            ((BQAlert)instance).setString(str);
        }
    }
    
    public Image getImage(){
        synchronized (Display.LCDUILock) {
            return ((BQAlert)instance).getImage().getShell();
        }
    }
    
    public void setImage(Image img){
        synchronized (Display.LCDUILock) {
            ((BQAlert)instance).setImage(img.getBQImage());
        }
    }
    
    public void setIndicator(Gauge indicator){
        synchronized (Display.LCDUILock) {
            ((BQAlert)instance).setIndicator((BQGauge)indicator.getBQItem());
        }
    }
    
    public Gauge getIndicator(){
        return (Gauge)((BQAlert)instance).getIndicator().getShell();
    }
    
    public void addCommand(Command cmd){
        if (cmd == null) {
            throw new NullPointerException();
        }
        if (cmd == DISMISS_COMMAND) {
            return;
        }

        synchronized (Display.LCDUILock) {
            super.addCommand(cmd);
        }
    }
    
    public void removeCommand(Command cmd){
        if (cmd == DISMISS_COMMAND) {
            return;
        }

        synchronized (Display.LCDUILock) {
            super.removeCommand(cmd);
        }
    }
    
    public void setCommandListener(CommandListener l){
        synchronized (Display.LCDUILock) {
            ((BQAlert)instance).setCommandListener(l);
        }
    }
}

⌨️ 快捷键说明

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