EXample9_3(主方法):

public class Example9_3 {
public static void main(String arg[]) {
	ComponentInwindow win=new ComponentInwindow();
	win.setBounds(100,100,450,260);
	win.setTitle("常用组件");
}
}

ComponentInwindow.java

package qq;

import java.awt.*;
import javax.swing.*;
public class ComponentInwindow extends JFrame {
JCheckBox checkBox1,checkBox2;//复选框
JRadioButton radioM,radioF;//
ButtonGroup group;
JComboBox<String> comBox;
public   ComponentInwindow() {
	init();
	setVisible(true);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
void init() {
	setLayout(new FlowLayout());
	comBox=new JComboBox<String>();
	checkBox1=new JCheckBox("喜欢音乐");
	checkBox1=new JCheckBox("喜欢旅游");
	group =new ButtonGroup();
	radioM=new JRadioButton("男");
	radioF=new JRadioButton("女");
	group.add(radioM);
	group.add(radioF);
	add(checkBox1);
	add(checkBox2);
	add(radioM);
	add(radioF);
	comBox.addItem("音乐天地");
	comBox.addItem("武术天地");
	add(comBox);
}
}