packageXiangmu9;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassT1extendsJFrameimplementsActionListener{CheckboxGroupbox;Checkbox[]ch=newCheckbox[8...
package Xiangmu9;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class T1 extends JFrame implements ActionListener
{
CheckboxGroup box;
Checkbox[] ch=new Checkbox[8];
JButton button;
JPanel p1,p2;
public T1()
{
super("选题");
p1=new JPanel();
p2=new JPanel();
p1.setLayout(new GridLayout(2,4));
box=new CheckboxGroup();
Checkbox[] ch=new Checkbox[8];
ch[0]=new Checkbox("第一单元",box,true);
ch[1]=new Checkbox("第二单元",box,true);
ch[2]=new Checkbox("第三单元",box,true);
ch[3]=new Checkbox("第四单元",box,true);
ch[4]=new Checkbox("第五单元",box,true);
ch[5]=new Checkbox("第六单元",box,true);
ch[6]=new Checkbox("第七单元",box,true);
ch[7]=new Checkbox("第八单元",box,true);
p1.add(ch[0]);
p1.add(ch[1]);
p1.add(ch[2]);
p1.add(ch[3]);
p1.add(ch[4]);
p1.add(ch[5]);
p1.add(ch[6]);
p1.add(ch[7]);
JButton button=new JButton("确定");
button.addActionListener(this);
p2.add(button);
p1.setSize(400, 100);
button.setBounds(280, 120, 80, 30);
p2.setLayout(null);
this.add(p1);
this.add(p2);
this.setSize(400,200);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[])
{
new T1();
}
public void actionPerformed(ActionEvent e)
{
Object temp = e.getSource();
if(temp==button)
{
new Main();
}
}
}
展开