SWING控件问题
importjava.awt.*;importjavax.swing.*;publicclassformextendsJFrame{JLabeljl1,jl2;JPane...
import java.awt.*;
import javax.swing.*;
public class form extends JFrame{
JLabel jl1,jl2;
JPanel jp1,jp2;
JComboBox jcb;
JList jlist;
JScrollPane jsp;
public static void main(String []args){
form fr=new form();
}
public form(){
//定义组件
jl1=new JLabel("你的籍贯");
jl2=new JLabel("旅游地点");
jp1=new JPanel();
jp2=new JPanel();
String []BornPlace={"北京","河北","天津"};
jcb=new JComboBox(BornPlace);
String []TravelPlace={"天安门","故宫","长城"};
jlist=new JList(TravelPlace);
jsp=new JScrollPane(jlist);
jlist.setVisibleRowCount(2);
//设置布局
this.setLayout(new GridLayout(2,1));
//添加组件
jp1.add(jl1);
jp1.add(jcb);
jp2.add(jl2);
jp2.add(jsp);
//设置窗体属性
this.setSize(400, 400);
this.setLocation(400, 350);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
运行后什么东东都不出,怎么回事?? 展开
import javax.swing.*;
public class form extends JFrame{
JLabel jl1,jl2;
JPanel jp1,jp2;
JComboBox jcb;
JList jlist;
JScrollPane jsp;
public static void main(String []args){
form fr=new form();
}
public form(){
//定义组件
jl1=new JLabel("你的籍贯");
jl2=new JLabel("旅游地点");
jp1=new JPanel();
jp2=new JPanel();
String []BornPlace={"北京","河北","天津"};
jcb=new JComboBox(BornPlace);
String []TravelPlace={"天安门","故宫","长城"};
jlist=new JList(TravelPlace);
jsp=new JScrollPane(jlist);
jlist.setVisibleRowCount(2);
//设置布局
this.setLayout(new GridLayout(2,1));
//添加组件
jp1.add(jl1);
jp1.add(jcb);
jp2.add(jl2);
jp2.add(jsp);
//设置窗体属性
this.setSize(400, 400);
this.setLocation(400, 350);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
运行后什么东东都不出,怎么回事?? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询