softkeyimpl.java

来自「j2me下的1套UI框架.包含j2me开发中会应用的各种低级组件」· Java 代码 · 共 69 行

JAVA
69
字号
package com.jmobilecore.ui;

import com.jmobilecore.ui.core.SoftKey;
import com.jmobilecore.ui.core.EventListener;

/**
 * This class is implementation of abstract class <code>SoftKey</code>
 * The class keeps information about returning value and reference to
 * it's parent (owner).
 *
 * @author Greg Gridin
 */
public class SoftKeyImpl extends SoftKey {

    /**
     * Parent (owner) of this soft key
     */
    public EventListener parent = null;

    /**
     * Result to report
     */
    public int rslt;

    /**
     * Creates a new <code>SoftKeyImpl</code> instance.
     *
     * @param label The <code>SoftKey</code> label.
     * @see #performAction
     */
    public SoftKeyImpl(String label) {
        this(label, null, EventListener.EVENT_OK);
    }

    /**
     * Creates a new <code>SoftKeyImpl</code> instance.
     *
     * @param label  The <code>SoftKey</code> label.
     * @param parent The parent (owner) of this soft key.
     * @see #performAction
     */
    public SoftKeyImpl(String label, EventListener parent) {
        this(label, parent, EventListener.EVENT_OK);
    }

    /**
     * Creates a new <code>SoftKeyImpl</code> instance.
     *
     * @param label  The <code>SoftKey</code> label.
     * @param parent The parent (owner) of this soft key.
     * @param rslt   The result to report.
     * @see #performAction
     */
    public SoftKeyImpl(String label, EventListener parent, int rslt) {
        super(label);
        this.parent = parent;
        this.rslt = rslt;
    }

    /**
     * Performs an action - informs the parent that action is performed
     */
    public void performAction() {
        if (parent != null) {
            parent.actionPerformed(rslt);
        }
    }
} // class SoftKeyImpl

⌨️ 快捷键说明

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