窗口

package CK;


public class ZHU {




public static void main(String args[]){
chuangkou win = new chuangkou();
win.setBounds(100,100,310,260);
win.setTitle("常用组件");





}

}

package CK;




import java.awt.*;
import javax.swing.*;
public class chuangkou extends JFrame {
JCheckBox checkBox1,checkBox2,checkBox3;
JRadioButton radio1,radio2;
ButtonGroup group;
JTextArea area;
Box baseBox,boxV1,boxV2,boxV3;
public chuangkou(){
hanshu();
setVisible (true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
void hanshu(){
setLayout(new FlowLayout());
boxV1=Box.createHorizontalBox();
boxV2=Box.createHorizontalBox();
boxV3=Box.createHorizontalBox();
boxV1.add(new JLabel ("兴趣:"));
checkBox1 = new JCheckBox("羽毛球");
checkBox2 = new JCheckBox("兵乓球");
checkBox3 = new JCheckBox("唱歌");
boxV1.add(checkBox1);
boxV1.add(checkBox2);
boxV1.add(checkBox3);
boxV2.add(new JLabel("性别:"));
group = new ButtonGroup();
radio1 = new JRadioButton("男");
radio2 = new JRadioButton("女");
group.add(radio1);
group.add(radio2);
boxV2.add(radio1);
boxV2.add(radio2);
boxV3.add(new JLabel("文本区:"));
area = new JTextArea(6,12);
boxV3.add(new JScrollPane(area));
baseBox=Box.createVerticalBox();
baseBox.add(boxV1);
baseBox.add(boxV2);
baseBox.add(boxV3);
add(baseBox);
}

}

窗口