JAVA GUI不显示组件
importjava.awt.*;importjavax.swing.*;publicclassMainClassextendsJFrame{JButtonfinish;...
import java.awt.*;import javax.swing.*;public class MainClass extends JFrame {JButton finish; //完成按钮JLabel baidu,qihu; //百度,360标签JTextField urlbaidu,url360; //文本框JPanel shang,zhong,xia; //上中下三个面板,上为百度云,中为360.下为完成按钮public static void main(String agrs[]){MainClass usrpan=new MainClass(); //在主函数创建对对象}public MainClass(){//======窗体属性this.setVisible(true); //显示窗体this.setTitle("********");//设置标题this.setSize(500,300);//窗体大小this.setLocation(300,300);//启动时位置this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setLayout(new GridLayout(3,1,30,30));//=======在构造方法中创建组件shang=new JPanel();//上面板zhong=new JPanel();//中面板xia=new JPanel();//下面板finish=new JButton("完成");//完成按钮baidu=new JLabel("百度云");//百度云标签qihu=new JLabel("360云盘");//360云盘标签urlbaidu=new JTextField(10);//百度云urlurl360=new JTextField(10);//360url//========在构造方法添加组件shang.add(baidu);shang.add(urlbaidu);zhong.add(qihu);zhong.add(url360);xia.add(finish);this.add(shang,BorderLayout.NORTH);//北部this.add(zhong,BorderLayout.CENTER);//南部this.add(xia,BorderLayout.SOUTH); //东部}}
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询