1、importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassWorkerpublicstaticvoidmain(Stringargs)JFramef=newJFrame(“西南财经大学职工“);JPanelcontentpane=newJPanel();contentpane.setLayout(newFlowLayout(FlowLayout.LEFT);f.setContentPane(contentpane);ImageIconicon=newImageIcon(“woker,dif“);JLabell1
2、=newJLabel(“姓名职工编号信息“,icon);JLabell2=newJLabel(“你有哪些兴趣爱好?“);JTextFieldtf=newJTextField(“四川省成都市“);JRadioButtonrad1=newJRadioButton(“男“);JRadioButtonrad2=newJRadioButton(“女“);JCheckBox c1=newJCheckBox(“篮球“,false);JCheckBox c2=newJCheckBox(“音乐“,false);JCheckBox c3=newJCheckBox(“舞蹈“,false);JCheckBox c4=
3、newJCheckBox(“主持“,false);ButtonGroupbg1=newButtonGroup();bg1.add(rad1);bg1.add(rad2);JTextAreata=newJTextArea(“个人简介信息“);contentpane.add(l1);contentpane.add(tf);contentpane.add(ta);contentpane.add(l2);contentpane.add(bg1);contentpane.add(bg2);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setSize
4、(600,400);f.setVisible(true);importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassTestpublicstaticvoidmain(Stringargs)JFramef=newJFrame(“西南财经大学职工“);JPanelcontentpane=newJPanel();contentpane.setLayout(newFlowLayout(FlowLayout.LEFT);ImageIconicon=newImageIcon(“woker,dif“);JLabell1=ne
5、wJLabel(“姓名职工编号信息“);l1.setIcon(icon);/这里分开设置JLabell2=newJLabel(“你有哪些兴趣爱好?“);JTextFieldtf=newJTextField(“四川省成都市“);JRadioButtonrad1=newJRadioButton(“男“);JRadioButtonrad2=newJRadioButton(“女“);JCheckBoxc1=newJCheckBox(“篮球“,false);JCheckBoxc2=newJCheckBox(“音乐“,false);JCheckBoxc3=newJCheckBox(“舞蹈“,false);
6、JCheckBoxc4=newJCheckBox(“主持“,false);ButtonGroupbg1=newButtonGroup();bg1.add(rad1);bg1.add(rad2);JTextAreata=newJTextArea(“个人简介信息“);contentpane.add(l1);contentpane.add(tf);contentpane.add(ta);contentpane.add(l2);contentpane.add(rad1);/添加rad就行了,不能添加按钮组的contentpane.add(rad2);f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);f.setSize(600,400);f.setContentPane(contentpane);f.setVisible(true);