jmcheckbox.java

来自「梦界家园程序开发基底框架」· Java 代码 · 共 113 行

JAVA
113
字号
package jm.framework.gui.module;

import java.awt.* ;

import javax.swing.* ;

public class JMCheckBox extends JCheckBox
{
	private static final long serialVersionUID = -5611366293816738912L;
	
	public static final String CLASS_NAME = "JMCheckBox" ;
    /**
     * Creates an initially unselected check box button with no text, no icon.
     */
    public JMCheckBox () {
        this(null, null, false);
    }

    /**
     * Creates an initially unselected check box with an icon.
     *
     * @param icon  the Icon image to display
     */
    public JMCheckBox(Icon icon) {
        this(null, icon, false);
    }

    /**
     * Creates a check box with an icon and specifies whether
     * or not it is initially selected.
     *
     * @param icon  the Icon image to display
     * @param selected a boolean value indicating the initial selection
     *        state. If <code>true</code> the check box is selected
     */
    public JMCheckBox(Icon icon, boolean selected) {
        this(null, icon, selected);
    }

    /**
     * Creates an initially unselected check box with text.
     *
     * @param text the text of the check box.
     */
    public JMCheckBox (String text) {
        this(text, null, false);
    }

    /**
     * Creates a check box where properties are taken from the
     * Action supplied.
     *
     * @since 1.3
     */
    public JMCheckBox(Action a) {
        this();
        setAction(a);
    }

    /**
     * Creates a check box with text and specifies whether
     * or not it is initially selected.
     *
     * @param text the text of the check box.
     * @param selected a boolean value indicating the initial selection
     *        state. If <code>true</code> the check box is selected
     */
    public JMCheckBox (String text, boolean selected) {
        this(text, null, selected);
    }

    /**
     * Creates an initially unselected check box with
     * the specified text and icon.
     *
     * @param text the text of the check box.
     * @param icon  the Icon image to display
     */
    public JMCheckBox(String text, Icon icon) {
        this(text, icon, false);
    }

    /**
     * Creates a check box with text and icon,
     * and specifies whether or not it is initially selected.
     *
     * @param text the text of the check box.
     * @param icon  the Icon image to display
     * @param selected a boolean value indicating the initial selection
     *        state. If <code>true</code> the check box is selected
     */
    public JMCheckBox (String text, Icon icon, boolean selected)
    {
        super(text, icon, selected);
        setBorderPainted(false);
        setHorizontalAlignment(LEADING);
        setDefault();
    }

    private void setDefault()
    {
        this.setBackground(Color.white);
//        this.setBorder(JMItemCode.BR_NORMAL);
        this.setFont(JMItemCode.FT_CHECKBOX);
        this.addKeyListener(new EnterKeyDeal());
    }

    public void setHelp ( String asHelp )
    {
        this.setToolTipText(asHelp);
    }
}

⌨️ 快捷键说明

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