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

📄 e752. creating a jcheckbox component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
By default, the state of the checkbox is off; to change the state, see e753 Getting and Setting the State of a JCheckbox Component. Also by default, the checkbox is left-justified and vertically centered. The methods to control the text alignment are identical to those of a JButton; see e748 Moving the Label/Icon Pair in a JButton Component. 
    // Create an action
    Action action = new AbstractAction("CheckBox Label") {
        // This method is called when the button is pressed
        public void actionPerformed(ActionEvent evt) {
            // Perform action
            JCheckBox cb = (JCheckBox)evt.getSource();
    
            // Determine status
            boolean isSel = cb.isSelected();
            if (isSel) {
                // The checkbox is now selected
            } else {
                // The checkbox is now deselected
            }
        }
    };
    
    // Create the checkbox
    JCheckBox checkBox = new JCheckBox(action);

⌨️ 快捷键说明

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