很急,大虾指教!!!!

lihui54120 2007-10-31 10:26:56
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();
}
}
这个代码为什么不能运行出现窗口!
...全文
101 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
anqini 2008-04-22
  • 打赏
  • 举报
回复

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();
}
}
commanager 2008-04-21
  • 打赏
  • 举报
回复
看来你问题解决了
lihui54120 2008-04-21
  • 打赏
  • 举报
回复
呵呵,才来看,感觉很多时候学习是很幼稚的,小问题,都要请教。
dxlove 2007-11-01
  • 打赏
  • 举报
回复
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 "));//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();
}
}
hejianhuacn 2007-11-01
  • 打赏
  • 举报
回复
最好把setVisible(true)放在对实例的调用里
pc144818 2007-11-01
  • 打赏
  • 举报
回复
把一楼说的哪个 LABEL 改了就可以了~
你那代码我运行了 是可以用的~
lihui54120 2007-10-31
  • 打赏
  • 举报
回复
但是没有窗口出现呀,就是那个地方改了,也没有!还是我环境配置有问题吗?运行不提示错误,但是没有结果出现!
wjs2338 2007-10-31
  • 打赏
  • 举报
回复
Label啊,不是Lable

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧