java,以下的代码为何不能实现? myeclipse中,按运行之后,无显示图形界面出来。
import(省略..超字数了)。publicclassStartextendsJInternalFrame{//initprivateJButtonjb3Name,jb...
import (省略..超字数了)。
public class Start extends JInternalFrame
{ //init
private JButton jb3Name,jb3Birth,jb3Address,jb0Check,jb2Confirm,jb2Delete,jb2Cancel;
private JLabel lb00,lb3Format,lb0Name,lb0Birth ,lb0Address,lb1Size,lb2Name,lb2Birth,lb2Phone,lb2Address,lb2Remarks;
private JTextField tf0Name,tf0Birth,tf0Address,tf2Name,tf2Birth,tf2Phone,tf2Address,tf2Remarks;
Container con;
public Start()
{
super("通讯录");
//界面参数
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width-800)/2, (screenSize.height-600)/2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setSize(800,600);
con =this.getContentPane();
lb00 = new JLabel("***********************************");
Font f = new Font("新宋体", 0, 14);
//搜索单元
lb0Name = new JLabel("按姓名:");
lb0Birth = new JLabel("按月份:");
lb0Address = new JLabel("按地址(模糊关键字):");
tf0Name = new JTextField(10);
tf0Birth = new JTextField(10);
tf0Address = new JTextField(10);
jb0Check = new JButton("开始搜索");
//排序单元
lb3Format = new JLabel("排序方式:");
jb3Name = new JButton("名字");
jb3Birth = new JButton("生日");
jb3Address = new JButton("地址");
//表格单元
lb1Size = new JLabel("↓↓预览↓↓"); getContentPane().setLayout(null);
//设置各单元的坐标等
//排序单元
lb3Format.setFont(f);
con.add(lb3Format);
lb3Format.setBounds(30,40,10,10);
jb3Name.setFont(f);
con.add(jb3Name);
jb3Name.setBounds(120,40,10,10);
jb3Birth.setFont(f);
con.add(jb3Birth);
jb3Birth.setBounds(180,40,10,10);
jb3Address.setFont(f);
con.add(jb3Address);
jb3Address.setBounds(240,40,10,10);
con.add(lb00);
lb00.setBounds(30,60,200,10);
//搜索单元
lb0Name.setFont(f);
con.add(lb0Name);
lb0Name.setBounds(30,100,10,10);
lb0Birth.setFont(f);
con.add(lb0Birth);
lb0Birth.setBounds(350,100,10,10);
lb0Address.setFont(f);
con.add(lb0Address);
lb0Address.setBounds(30,130,10,10);
tf0Name.setFont(f);
con.add(tf0Name);
tf0Name.setBounds(120,100,10,10);
tf0Birth.setFont(f);
con.add(tf0Birth);
tf0Birth.setBounds(440,100,10,10);
tf0Address.setFont(f);
con.add(tf0Address);
tf0Address.setBounds(120,130,10,10);
jb0Check.setFont(f);
con.add(jb0Check);
jb0Check.setBounds(30,160,10,10);
con.add(lb00);
lb00.setBounds(30,190,200,10);
lb1Size.setFont(f);
con.add(lb1Size);
setVisible(true);
}
public static void main(String args[])
{
new Start();
}
}
好吧..其实原因在于继承: JInternalFrame..
继承JFrame才对..那个是内部继承..哎.. 展开
public class Start extends JInternalFrame
{ //init
private JButton jb3Name,jb3Birth,jb3Address,jb0Check,jb2Confirm,jb2Delete,jb2Cancel;
private JLabel lb00,lb3Format,lb0Name,lb0Birth ,lb0Address,lb1Size,lb2Name,lb2Birth,lb2Phone,lb2Address,lb2Remarks;
private JTextField tf0Name,tf0Birth,tf0Address,tf2Name,tf2Birth,tf2Phone,tf2Address,tf2Remarks;
Container con;
public Start()
{
super("通讯录");
//界面参数
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width-800)/2, (screenSize.height-600)/2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setSize(800,600);
con =this.getContentPane();
lb00 = new JLabel("***********************************");
Font f = new Font("新宋体", 0, 14);
//搜索单元
lb0Name = new JLabel("按姓名:");
lb0Birth = new JLabel("按月份:");
lb0Address = new JLabel("按地址(模糊关键字):");
tf0Name = new JTextField(10);
tf0Birth = new JTextField(10);
tf0Address = new JTextField(10);
jb0Check = new JButton("开始搜索");
//排序单元
lb3Format = new JLabel("排序方式:");
jb3Name = new JButton("名字");
jb3Birth = new JButton("生日");
jb3Address = new JButton("地址");
//表格单元
lb1Size = new JLabel("↓↓预览↓↓"); getContentPane().setLayout(null);
//设置各单元的坐标等
//排序单元
lb3Format.setFont(f);
con.add(lb3Format);
lb3Format.setBounds(30,40,10,10);
jb3Name.setFont(f);
con.add(jb3Name);
jb3Name.setBounds(120,40,10,10);
jb3Birth.setFont(f);
con.add(jb3Birth);
jb3Birth.setBounds(180,40,10,10);
jb3Address.setFont(f);
con.add(jb3Address);
jb3Address.setBounds(240,40,10,10);
con.add(lb00);
lb00.setBounds(30,60,200,10);
//搜索单元
lb0Name.setFont(f);
con.add(lb0Name);
lb0Name.setBounds(30,100,10,10);
lb0Birth.setFont(f);
con.add(lb0Birth);
lb0Birth.setBounds(350,100,10,10);
lb0Address.setFont(f);
con.add(lb0Address);
lb0Address.setBounds(30,130,10,10);
tf0Name.setFont(f);
con.add(tf0Name);
tf0Name.setBounds(120,100,10,10);
tf0Birth.setFont(f);
con.add(tf0Birth);
tf0Birth.setBounds(440,100,10,10);
tf0Address.setFont(f);
con.add(tf0Address);
tf0Address.setBounds(120,130,10,10);
jb0Check.setFont(f);
con.add(jb0Check);
jb0Check.setBounds(30,160,10,10);
con.add(lb00);
lb00.setBounds(30,190,200,10);
lb1Size.setFont(f);
con.add(lb1Size);
setVisible(true);
}
public static void main(String args[])
{
new Start();
}
}
好吧..其实原因在于继承: JInternalFrame..
继承JFrame才对..那个是内部继承..哎.. 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询