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

📄 checkboxdemo.java.bak

📁 java经典的源代码 我非常喜欢这个源代码 对于编程很有好处
💻 BAK
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;

public class CheckboxDemo extends JFrame {
  private JPanel contentPane;
  private XYLayout xYLayout1 = new XYLayout();
  private XYLayout xYLayout2 = new XYLayout();
  private Checkbox checkbox1 = new Checkbox();
  private Checkbox checkbox2 = new Checkbox();
  private Checkbox checkbox3 = new Checkbox();
  private Checkbox checkbox4 = new Checkbox();
  private CheckboxGroup checkboxGroup1 = new CheckboxGroup();
  private Checkbox checkbox5 = new Checkbox();
  private Checkbox checkbox6 = new Checkbox();
  private Label label1 = new Label();
  private Label label2 = new Label();
  private Label label3 = new Label();
  private Label label4 = new Label();
  //Construct the frame
  public CheckboxDemo() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("使用 Checkbox");
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
  private void jbInit() throws Exception {
    checkbox1.setLabel("足球");
    this.getContentPane().setLayout(xYLayout2);
    checkbox2.setLabel("篮球");
    checkbox3.setLabel("网球");
    checkbox4.setCheckboxGroup(checkboxGroup1);
    checkbox4.setLabel("本科");
    checkboxGroup1.setSelectedCheckbox(checkbox4);
    checkbox5.setCheckboxGroup(checkboxGroup1);
    checkbox5.setLabel("硕士");
    checkbox6.setCheckboxGroup(checkboxGroup1);
    checkbox6.setLabel("博士");
    label1.setText("这是Checkbox");
    label2.setText("这是CheckboxGrooup");
    label3.setText("请选择你的爱好");
    label4.setText("请选择你的学历");
    this.getContentPane().add(checkbox3, new XYConstraints(90,154, -1, -1));
    this.getContentPane().add(checkbox1, new XYConstraints(90, 87, -1, -1));
    this.getContentPane().add(checkbox2, new XYConstraints(90, 121, -1, -1));
    this.getContentPane().add(checkbox5, new XYConstraints(243, 119, -1, -1));
    this.getContentPane().add(checkbox4, new XYConstraints(243, 87, -1, -1));
    this.getContentPane().add(checkbox6, new XYConstraints(243, 151, -1, -1));
    this.getContentPane().add(label1,  new XYConstraints(49, 36, 118, 37));
    this.getContentPane().add(label2,   new XYConstraints(221, 32, 137, 44));
    this.getContentPane().add(label3,   new XYConstraints(66, 211, 107, 34));
    this.getContentPane().add(label4,   new XYConstraints(229, 199, 125, 45));
  }
  public static void main(String args[]){
    CheckboxDemo f=new CheckboxDemo ();
    f.show();
  } 
}

⌨️ 快捷键说明

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