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

📄 checkboxandradiodemo.java

📁 精通JBuilder2006 源代码 精通JBuilder2006 源代码
💻 JAVA
字号:
package chapter6.component;

import java.awt.*;
import javax.swing.*;

public class CheckBoxAndRadioDemo extends JFrame {

    public CheckBoxAndRadioDemo() {
        Container contentPane = this.getContentPane();
        contentPane.setLayout(new GridLayout(3, 1));
        JPanel jPanel1 = new JPanel(new FlowLayout());
        JPanel jPanel2 = new JPanel(new FlowLayout());
        JPanel jPanel3 = new JPanel(new FlowLayout());
        jPanel1.setBorder(BorderFactory.createTitledBorder("请您选择:"));
        jPanel2.setBorder(BorderFactory.createTitledBorder("请您选择:"));
        jPanel3.setBorder(BorderFactory.createTitledBorder("请您选择:"));
        JCheckBox jCheckBox1 = new JCheckBox("A");
        JCheckBox jCheckBox2 = new JCheckBox("B");
        JCheckBox jCheckBox3 = new JCheckBox("C");
        jPanel1.add(jCheckBox1);
        jPanel1.add(jCheckBox2);
        jPanel1.add(jCheckBox3);
        JRadioButton jRadioButton1 = new JRadioButton("A");
        JRadioButton jRadioButton2 = new JRadioButton("B");
        JRadioButton jRadioButton3 = new JRadioButton("C");
        jPanel2.add(jRadioButton1);
        jPanel2.add(jRadioButton2);
        jPanel2.add(jRadioButton3);
        JRadioButton jRadioButton4 = new JRadioButton("A");
        JRadioButton jRadioButton5 = new JRadioButton("B");
        JRadioButton jRadioButton6 = new JRadioButton("C");
        ButtonGroup buttonGroup1 = new ButtonGroup();
        buttonGroup1.add(jRadioButton4);
        buttonGroup1.add(jRadioButton5);
        buttonGroup1.add(jRadioButton6);
        jPanel3.add(jRadioButton4);
        jPanel3.add(jRadioButton5);
        jPanel3.add(jRadioButton6);
        contentPane.add(jPanel1);
        contentPane.add(jPanel2);
        contentPane.add(jPanel3);
        this.setTitle("CheckBoxAndRadioDemo");
        this.setSize(300, 300);
        this.setLocation(400,400);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        CheckBoxAndRadioDemo test = new CheckBoxAndRadioDemo();
    }
}

⌨️ 快捷键说明

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