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

📄 dialog.java

📁 这是我们学校教的j2me程序开发实例从入门到精通自带关盘的源代码
💻 JAVA
字号:
/*
 * Created on 2004-7-10
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author P2800
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */

package com.north.phonebook.ui;
import javax.microedition.lcdui.*;

//The base class for a set of general-purpose
//dialogs. To use, create a concrete instance
//of this class, set the dialog listener,
//and then call display.

public abstract class Dialog
{
    protected Display display;
    protected DialogListener listener;
    protected Displayable restore;
    private int eventID;
    private Object[] obj;

    protected Dialog(Display display)
    {
        this.display = display;
    }
    

    /**
     * @return Returns the obj.
     */
    public Object[] getObj()
    {
        return obj;
    }
    /**
     * @param obj The obj to set.
     */
    public void setObj(Object[] obj)
    {
        this.obj = obj;
    }
    /**
     * @return Returns the eventID.
     */
    public int getEventID()
    {
        return eventID;
    }
    /**
     * @param eventID The eventID to set.
     */
    public void setEventID(int eventID)
    {
        this.eventID = eventID;
    }
    // Dismisses the dialog, restoring the old
    // displayable, if any. This is normally done
    // by the dialog itself in response to commands,
    // but can also be called by the application
    // in response to some other event, such as a
    // timer expiration. The code is passed directly
    // to the dialog listener, if any.

    public void dismiss(int code)
    {
        Displayable curr = display.getCurrent();
        if (curr != getDisplayable())
            return;

        if (restore != null)
        {
            display.setCurrent(restore);
        } else
        {
            display.setCurrent(new Form(""));
        }

        if (listener != null)
        {
            listener.dialogDismissed(this, code);
        }
    }

    // Displays the dialog, saving the current
    // displayable for later restoration.

    public void display()
    {
        Displayable curr = display.getCurrent();
        Displayable dialog = getDisplayable();

        if (curr != dialog)
        {
            restore = curr;
            display.setCurrent(dialog);
        }
    }
    public void display(int event)
    {
        Displayable curr = display.getCurrent();
        Displayable dialog = getDisplayable();
        this.eventID = event;

        if (curr != dialog)
        {
            restore = curr;
            display.setCurrent(dialog);
        }
    }
    
    public void display(int event,Object[] obj)
    {
        Displayable curr = display.getCurrent();
        Displayable dialog = getDisplayable();
        this.eventID = event;
        this.obj = obj;

        if (curr != dialog)
        {
            restore = curr;
            display.setCurrent(dialog);
        }
    }

    // Returns the registered dialog listener.

    public DialogListener getDialogListener()
    {
        return listener;
    }

    // Subclasses implement this method to return
    // the actual object to display on the screen.

    protected abstract Displayable getDisplayable();

    // Registers a dialog listener.

    public void setDialogListener(DialogListener l)
    {
        listener = l;
    }

}

⌨️ 快捷键说明

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