用java写了个简单的GUI,编译成功,组件怎么都显示不出来,开发工具用的是myeclipes 8.5。
代码如下:packagetest3;importjava.awt.*;importjavax.swing.*;publicclassDemo3extendsJFrame{...
代码如下:
package test3;
import java.awt.*;
import javax.swing.*;
public class Demo3 extends JFrame {
private static final long serialVersionUID = 1L;
JPanel jp1,jp2,jp3;
JLabel jl1,jl2;
JButton jb1,jb2;
JTextField jtf1;
JPasswordField jpf1;
public Demo3(){
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
jl1=new JLabel("用户名:");
jl2=new JLabel("密 码:");
jb1=new JButton("登录");
jb2=new JButton("取消");
jtf1=new JTextField(10);
jpf1=new JPasswordField(13);
this.setLayout(new GridLayout(3,1));
jp1.add(jl1);
jp1.add(jtf1);
jp2.add(jl2);
jp2.add(jpf1);
jp3.add(jb1);
jp3.add(jb2);
this.setTitle("图书管理系统登录");
this.setSize(300,150);
this.setLocation(300, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
@SuppressWarnings("unused")
Demo3 demo3=new Demo3();
}
} 展开
package test3;
import java.awt.*;
import javax.swing.*;
public class Demo3 extends JFrame {
private static final long serialVersionUID = 1L;
JPanel jp1,jp2,jp3;
JLabel jl1,jl2;
JButton jb1,jb2;
JTextField jtf1;
JPasswordField jpf1;
public Demo3(){
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
jl1=new JLabel("用户名:");
jl2=new JLabel("密 码:");
jb1=new JButton("登录");
jb2=new JButton("取消");
jtf1=new JTextField(10);
jpf1=new JPasswordField(13);
this.setLayout(new GridLayout(3,1));
jp1.add(jl1);
jp1.add(jtf1);
jp2.add(jl2);
jp2.add(jpf1);
jp3.add(jb1);
jp3.add(jb2);
this.setTitle("图书管理系统登录");
this.setSize(300,150);
this.setLocation(300, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
@SuppressWarnings("unused")
Demo3 demo3=new Demo3();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询