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

📄 listcheckbox.java

📁 开发j2me 手机程序必须的用到的。文件较小
💻 JAVA
字号:
package com.jmobilecore.ui.core;

import javax.microedition.lcdui.Font;

public class ListCheckbox extends SimpleCheckbox implements ListComponent {

    /**
     * A key stoke that ia associated with a list checkbox.
     * To remove you have to assign to it <code>PlatformCanvas.KEY_UNDEFINED</code> value
     */
    protected int shortcut = PlatformCanvas.KEY_UNDEFINED;

    /**
     * This field indicates the command has been issued
     * by a  particular list checkbox.
     * By default the <code>actionCommand</code>
     * is the label of the list checkbox, unless it has been
     * explicitly set to a different value.
     */
    protected Object actionCommand = null;

    /**
     * Create a list checkbox
     *
     * @param label    the label for this list checkbox.
     */
    public ListCheckbox(String label, boolean state) {
        this(label, Style.TEXT_FONT, state, PlatformCanvas.KEY_UNDEFINED, label);
    }

    /**
     * Create a list checkbox with an associated keyboard shortcut.
     *
     * @param label    the label for this list checkbox.
     * @param font     the label font
     * @param shortcut key code associated witha list checkbox
     */
    public ListCheckbox(String label, Font font, boolean state, int shortcut) {
        this(label, font, state, shortcut, label);
    }

    /**
     * Create a list checkbox with an associated keyboard shortcut and custom action.
     *
     * @param label    the label for this list checkbox.
     * @param font     the label font
     * @param shortcut key code associated witha list checkbox.
     * @param action   custom action for the <code>ListCheckbox</code>
     */
    public ListCheckbox(String label, Font font, boolean state, int shortcut, Object action) {
        super(label, font, state);
        setShortcut(shortcut);
        setAction(action);
    }

    /**
     * Get the key code shortcut for this <code>ListCheckbox</code>
     * This method is required by <code>ListComponent</code> interface
     *
     * @return the keycode shortcut
     */
    public int getShortcut() {
        return shortcut;
    }

    /**
     * Sets the key code shortcut for this <code>ListCheckbox</code>
     * This method is required by <code>ListComponent</code> interface
     *
     * @param shortcut the keycode - new shortcut value
     */
    public void setShortcut(int shortcut) {
        this.shortcut = shortcut;
    }

    /**
     * Get the object representing the <code>ListCheckbox</code>'s action
     * This method is required by <code>ListComponent</code> interface
     *
     * @return the object associated with this <code>ListLabel</code>
     */
    public Object getAction() {
        return actionCommand;
    }

    /**
     * Sets the object as <code>ListCheckbox</code>'s action
     * This method is required by <code>ListComponent</code> interface
     *
     * @param action the object - new action value
     */
    public void setAction(Object action) {
        this.actionCommand = action;
    }

    /**
     * Class destructor. Helps VM to perform garbage collection
     */
    public void destructor() {
        actionCommand = null;
    }

} // class ListCheckbox

⌨️ 快捷键说明

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