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

📄 checkboxgroup.java

📁 j2me下的1套UI框架.包含j2me开发中会应用的各种低级组件
💻 JAVA
字号:
package com.jmobilecore.ui.core;

/**
 * The <code>CheckboxGroup</code> class is used to group together
 * a set of <code>Checkbox</code> buttons.
 * Exactly one check box button in a <code>CheckboxGroup</code> can
 * be in the "on" state at any given time. Pushing any
 * button sets its state to "on" and forces any other button that
 * is in the "on" state into the "off" state.
 *
 * @author Greg Gridin
 * @see com.jmobilecore.ui.core.Checkbox
 */
public class CheckboxGroup {

    /**
     * The current choice.
     */
    public Checkbox selectedCheckbox = null;

    /**
     * Sets the currently selected check box in this group
     * to be the specified check box.
     * This method sets the state of that check box to "on" and
     * sets all other check boxes in the group to be off.
     * <p/>
     * If the check box argument is <tt>null</tt>, all check boxes
     * in this check box group are deselected. If the check box argument
     * belongs to a different check box group, this method does
     * nothing.
     *
     * @param box the <code>Checkbox</code> to set as the
     *            current selection.
     * @see com.jmobilecore.ui.core.Checkbox
     * @see com.jmobilecore.ui.core.CheckboxGroup#setSelectedCheckbox
     */
    public void setSelectedCheckbox(Checkbox box) {
        if (box != null && box.group != this) {
            return;
        }
        Checkbox oldChoice = this.selectedCheckbox;
        this.selectedCheckbox = box;
        if (oldChoice != null && oldChoice != box && oldChoice.group == this) {
            oldChoice.state = false;
        }
        if (box != null && oldChoice != box && !box.state) {
            box.state = true;
        }
    }
}

⌨️ 快捷键说明

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