求大神给看看,图形化界面,运行后窗口是空白,没组件。
package lianxi;import java.awt.BorderLayout;
import java.awt.Color;
import java.
import java.awt.Dimension;
import java.awt.Label;
import java.awt.TextArea;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class MyPaneel extends JFrame {
JPanel panelsouth,panelcenter,panelnorth;
JLabel namelabel,sexlable,shuiguolable,countlabel,advantagelable;
JButton rewritebutton,querenbutton;
public MyPaneel() {
// TODO Auto-generated constructor stub
this.setResizable(false);
this.setBounds(200, 200, 650,300);
panelnorth=new JPanel();
this.setLayout(null);
namelabel=new JLabel("你的名字是:");
namelabel.setBounds(80, 20, 60, 30);
panelnorth.add(namelabel);
JTextField TextInput;
this.add(panelnorth);
panelnorth.setLayout(null);
TextInput=new JTextField(10);
TextInput.setBounds(160, 20,150, 30);
panelnorth.add(TextInput);
JLabel sexlabel = new JLabel("性别是:");
sexlabel.setBounds(160, 20, 60, 30);
panelnorth.add(sexlabel);
ButtonGroup buttonGroup=new ButtonGroup();
JRadioButton manradiobutton =new JRadioButton();
buttonGroup.add(manradiobutton);
manradiobutton.setSelected(true);
manradiobutton.setText("男");
manradiobutton.setBounds(200, 20, 60, 30);
panelnorth.add(manradiobutton);
JRadioButton womanradiobutton =new JRadioButton();
buttonGroup.add(womanradiobutton);
womanradiobutton.setSelected(true);
womanradiobutton.setText("女");
womanradiobutton.setBounds(300, 20, 60, 30);
panelnorth.add(womanradiobutton);
panelcenter=new JPanel();
panelcenter.setLayout(null);
shuiguolable=new JLabel("你最喜欢的水果是:");
shuiguolable.setBounds(80, 30, 60, 30);
panelcenter.add(shuiguolable);
JCheckBox applecheckbox=new JCheckBox();
applecheckbox.setText("苹果");
applecheckbox.setBounds(150, 30, 40, 20);
panelcenter.add(applecheckbox);
JCheckBox orangecheckbox=new JCheckBox();
orangecheckbox.setText("橘子");
orangecheckbox.setBounds(200, 30, 40, 20);
panelcenter.add(orangecheckbox);
JCheckBox bannarcheckbox=new JCheckBox();
bannarcheckbox.setText("香蕉");
bannarcheckbox.setBounds(250, 30, 40, 20);
panelcenter.add(bannarcheckbox);
JCheckBox peachcheckbox=new JCheckBox();
peachcheckbox.setText("桃子");
peachcheckbox.setBounds(300, 30, 40, 20);
panelcenter.add(peachcheckbox);
countlabel=new JLabel("你每次吃几个水果");
countlabel.setBounds(350, 30, 150, 20);
panelcenter.add(countlabel);
String[] count={"少于一个","吃一个","吃两个"};
JComboBox comboBox=new JComboBox(count);
comboBox.setEditable(true);
comboBox.setMaximumRowCount(3);
comboBox.insertItemAt("吃三个", 0);
comboBox.setSelectedItem("少于一个");
comboBox.setBounds(510, 30,100 , 30);
panelcenter.add(comboBox);
this.add(panelcenter);
panelsouth=new JPanel();
panelsouth.setLayout(null);
advantagelable=new JLabel("你觉得吃水果有什么好处");
advantagelable.setBounds(300, 60, 200, 30);
panelsouth.add(advantagelable);
JTextArea jTextArea=new JTextArea();
jTextArea.setColumns(15);
jTextArea.setRows(3);
jTextArea.setLineWrap(true);
JScrollPane scrollPane=new JScrollPane();
scrollPane.setViewportView(jTextArea);
Dimension dime=jTextArea.getPreferredSize();
scrollPane.setBounds(100, 100,dime.width,dime.height );
panelsouth.add(scrollPane);
querenbutton =new JButton("确定");
querenbutton.setBounds(400, 100, 70, 30);
panelsouth.add(querenbutton);
rewritebutton=new JButton("重写");
rewritebutton.setBounds(300, 150, 70, 30);
panelsouth.add(rewritebutton);
this.add(panelsouth);
this.setVisible(true);
}
}