import java.awt.*;
import java.awt.event.*;
public class EntranceFrame extends Frame{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new EntranceFrame("登陆");
}
public EntranceFrame(String title){
super(title);
setLocation(400,200);
setSize(400,300);
setResizable(false);
setLayout(new GridLayout(3,1));
Panel user=new Panel();
Panel passWord=new Panel();
Panel button=new Panel();
user.setLayout(new FlowLayout());
passWord.setLayout(new FlowLayout());
button.setLayout(new FlowLayout());
Label luser=new Label("账号:");
Label lpassWord=new Label("密码:");
TextField tfuser=new TextField(10);
TextField tfPassWord=new TextField(10);
Button ok=new Button("登陆");
Button exit=new Button("退出");
ok.addActionListener(new ButtonActionEvent());
exit.addActionListener(new ButtonActionEvent());
user.add(luser);
user.add(tfuser);
passWord.add(lpassWord);
passWord.add(tfPassWord);
button.add(ok);
button.add(exit);
add(user);
add(passWord);
add(button);
pack();
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
System.exit(0);
}
});
}
class ButtonActionEvent implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
//System.out.println(e.getActionCommand());
if(e.getActionCommand().equalsIgnoreCase("退出")){
setVisible(false);
System.exit(0);
}
if(e.getActionCommand().equalsIgnoreCase("登陆")){
System.out.println("正在登陆,请稍候片刻...");
/*
* 调用另外一线程验证用户的账号密码是否正确
* 如果正确,调用主窗口(Primary Frame)关闭登陆窗口(Entrance Frame)
* 如果不正确,弹出提示 清空用户名和密码等待重新验证
*/
}
}
}
}
import java.awt.event.*;
public class EntranceFrame extends Frame{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new EntranceFrame("登陆");
}
public EntranceFrame(String title){
super(title);
setLocation(400,200);
setSize(400,300);
setResizable(false);
setLayout(new GridLayout(3,1));
Panel user=new Panel();
Panel passWord=new Panel();
Panel button=new Panel();
user.setLayout(new FlowLayout());
passWord.setLayout(new FlowLayout());
button.setLayout(new FlowLayout());
Label luser=new Label("账号:");
Label lpassWord=new Label("密码:");
TextField tfuser=new TextField(10);
TextField tfPassWord=new TextField(10);
Button ok=new Button("登陆");
Button exit=new Button("退出");
ok.addActionListener(new ButtonActionEvent());
exit.addActionListener(new ButtonActionEvent());
user.add(luser);
user.add(tfuser);
passWord.add(lpassWord);
passWord.add(tfPassWord);
button.add(ok);
button.add(exit);
add(user);
add(passWord);
add(button);
pack();
setVisible(true);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
System.exit(0);
}
});
}
class ButtonActionEvent implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
//System.out.println(e.getActionCommand());
if(e.getActionCommand().equalsIgnoreCase("退出")){
setVisible(false);
System.exit(0);
}
if(e.getActionCommand().equalsIgnoreCase("登陆")){
System.out.println("正在登陆,请稍候片刻...");
/*
* 调用另外一线程验证用户的账号密码是否正确
* 如果正确,调用主窗口(Primary Frame)关闭登陆窗口(Entrance Frame)
* 如果不正确,弹出提示 清空用户名和密码等待重新验证
*/
}
}
}
}