import java.awt.*;
public class LoginFrame extends Frame
{
public LoginFrame()
{
super("UserLogin");
this.setSize(280,120);
this.setBackground(Color.lightGray);
this.setLocation(300,240);
this.setLayout(new FlowLayout());
this.add(new Lable("userid"));
this.add(new TextField("user1",20));
this.add(new Lable("password"));
this.add(new TextField(20));
this.add(new Button("OK"));
this.add(new Button("Cancel"));
this.setVisible(true);
}
public static void main(String args[])
{
new LoginFrame();
}
}
这个代码为什么不能运行出现窗口!
public class LoginFrame extends Frame
{
public LoginFrame()
{
super("UserLogin");
this.setSize(280,120);
this.setBackground(Color.lightGray);
this.setLocation(300,240);
this.setLayout(new FlowLayout());
this.add(new Lable("userid"));
this.add(new TextField("user1",20));
this.add(new Lable("password"));
this.add(new TextField(20));
this.add(new Button("OK"));
this.add(new Button("Cancel"));
this.setVisible(true);
}
public static void main(String args[])
{
new LoginFrame();
}
}
这个代码为什么不能运行出现窗口!
解决方案 »
- 大家快来啊。。。。单元测试,存放规范~~
- 求 Thinking in java 3ed 答案
- 从数据库中查询数据的效率问题!
- 怎样将char型的转成String型的?
- 请问怎样一个字符串怎样获得ASNI 字集的asc码值?
- java的数据库编程JDBC API,要不要去下载这个包模块,JAVA2中能直接支持吗?
- 请问同样的文件被压缩成.sxw文件和.zip文件后,两者有什么区别?(在线等候)
- 用JAVA怎样实现这个算法?
- 多重继承问题!请问这样改动后与原来有什么不同?
- 装JBUILDER5 个人版后,改装企业版,为什么装完后还是在个人版状态!很多控件用不了!
- java内存溢出测试工具
- 关于文件传输限速的问题
你那代码我运行了 是可以用的~
public class LoginFrame extends Frame
{
public LoginFrame()
{
super( "UserLogin ");
this.setSize(280,120);
this.setBackground(Color.lightGray);
this.setLocation(300,240);
this.setLayout(new FlowLayout());
this.add(new Lable( "userid "));//Label写错了
this.add(new TextField( "user1 ",20));
this.add(new Lable( "password "));//Label写错了
this.add(new TextField(20));
this.add(new Button( "OK "));
this.add(new Button( "Cancel "));
this.setVisible(true);
}
public static void main(String args[])
{
new LoginFrame();
}
}
package zhao;
import java.awt.*; import javax.swing.JFrame;
public class Test extends JFrame //建议用JFrame
{
public Test()
{
super("UserLogin");
this.setSize(280,120);
this.setBackground(Color.lightGray);
this.setLocation(300,240);
this.setLayout(new FlowLayout());
this.add(new Label("userid")); //Label写错了,应该在编译期间出错的!
this.add(new TextField("user1",20));
this.add(new Label("password"));
this.add(new TextField(20));
this.add(new Button("OK"));
this.add(new Button("Cancel"));
//加上这语句!
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String args[])
{
new Test();
}
}