| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 488 人关注过本帖
标题:位置不对呀.....该怎么调...?
只看楼主 加入收藏
simonray
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-6-17
收藏
 问题点数:0 回复次数:4 
位置不对呀.....该怎么调...?
import java.awt.*;
import java.awt.event.*;
public class abc extends WindowAdapter implements ActionListener
{
Frame f,f1,f2;
Button b1,b2;
TextField t1,t2;

public abc()
{
f=new Frame("Logining");
f.setSize(350,250);
f.setLayout(null);
f.setLocation(50,200); //指定框架位置

f1=new Frame("Logining failed!");
f1.setSize(250,150);
f1.setLocation(300,200);

f2=new Frame("Successed in login!");
f2.setSize(250,150);
f2.setLocation(200,100);

Panel p=new Panel();
f.add(p);
p.setBounds(50,50,300,300);

Label L1=new Label("Name:");
Label L2=new Label("Pawd:");
p.add(L1);
p.add(L2);
L1.setBounds(15,25,20,30);
L2.setBounds(30,50,20,30);

t1=new TextField(15);
t2=new TextField(15);
p.add(t1);
p.add(t2);
t1.setBounds(20,50,90,20);
t2.setBounds(90,100,90,20);
t2.setEchoChar('*'); //指定为*号显示

b1=new Button("OK");
b2=new Button("Reset");
p.add(b1);
p.add(b2);
b1.setBounds(50,90,40,20);
b2.setBounds(100,90,40,20);
b1.addActionListener(this);
b2.addActionListener(this);

f.setVisible(true);
f.addWindowListener(this);

}

public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
if(t1.getText().length()==0)
{
Panel p1=new Panel();
f1.add(p1);
p1.setBounds(20,20,130,40);
p1.add(new Label("User name doesn't in number!"));
f1.add(b2);
f1.setVisible(true);
}

if(t2.getText().length()<4)
{
Panel p2=new Panel();
f1.add(p2,"Center");
p2.setBounds(20,20,150,40);
p2.add(new Label("The password must more than four chars!"));
f1.add(b2);
f1.setVisible(true);
}

else
{
Panel p3=new Panel();
f2.add(p3);
p3.setBounds(20,20,100,40);
p3.add(new Label("Successed in login!"));
p3.add(b1);
f2.setVisible(true);
}
}

if(e.getSource()==b2)
{
f.setVisible(true);
f1.setVisible(false);
f2.setVisible(false);
}


}

public void windowClosing(WindowEvent e)
{

System.exit(0);

}

public static void main(String args[])
{
new abc();
}
}
搜索更多相关主题的帖子: 位置 
2007-06-21 19:50
simonray
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-6-17
收藏
得分:0 
以上是新手的我写的程序,调试后发现位置不是想像中那样.调了多次也无际于事.请大家指教.谢谢!

^o^ i believe i can fly , i believe i can touch the sky .
2007-06-21 19:53
simonray
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-6-17
收藏
得分:0 
还有的是怎么样谈判用户名不能为数字???

^o^ i believe i can fly , i believe i can touch the sky .
2007-06-21 19:54
pity1115
Rank: 1
等 级:新手上路
威 望:2
帖 子:184
专家分:0
注 册:2006-9-15
收藏
得分:0 
以下是引用simonray在2007-6-21 19:54:59的发言:
还有的是怎么样谈判用户名不能为数字???

Character.isDigit(char ch)


2007-06-21 21:42
simonray
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-6-17
收藏
得分:0 
谢谢.....

^o^ i believe i can fly , i believe i can touch the sky .
2007-06-22 21:24
快速回复:位置不对呀.....该怎么调...?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011936 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved