?? dialog2.txt
字號:
import java.awt.*;
import java.awt.event.*;
public class Dialog2 extends WindowAdapter implements ActionListener {
Frame f;
Button b1;
Button b2;
// Button db1;
Dialog d;
TextField txt1,txt2;
Label l3,l4,l5,l6;
Font f1,f2;
public static void main(String args[]) {
Dialog2 di = new Dialog2();
di.go();
}
public void go()
{
f=new Frame("dialog");
f.setLayout(new FlowLayout());
f.setBackground(Color.yellow );
//f.addWindowListener(this);
b1 =new Button("登錄");
b2=new Button("重置");
l3=new Label();
l4=new Label();
l5=new Label();
l6=new Label();
f1=new Font("TimesRoman",Font.PLAIN,20);
f2=new Font("TimesRoman",Font.BOLD,18);
//db1=new Button("確定");
d = new Dialog(f,"登錄結果",false);
d.setLayout(new FlowLayout());
d.add(l6);
d.add(l4);
d.add(l3);
//d.add(db1);
/*db1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
d.dispose();}
} );*/
d.setSize(300,130);
d.setBackground(Color.pink);
d.addWindowListener(this);
Label l5=new Label(" ");
f.add(l5);
Label l1=new Label("用戶名:");
l1.setFont(f2);
f.add(l1);
txt1=new TextField(5);
f.add(txt1);
Label l2=new Label("密碼:");
l2.setFont(f2);
f.add(l2);
txt2=new TextField(6);
txt2.setEchoChar('*');
f.add(txt2);
f.add(b1);
f.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
f.setSize(180,190);
f.show();
}
public void windowClosing(WindowEvent e){
System.exit(0);
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand()=="重置")
{ txt1.setText("");
txt2.setText(""); }
else
{ String s1=txt1.getText();
String s2=txt2.getText();
if (e.getActionCommand()=="登錄"&&s1.equals("admin") && s2.equals("123456"))
{ l4.setText(" ");
l3.setText("Welcome! Log in success!");
l3.setFont(f1);
d.show();}
else
{ l6.setText(" ");
l3.setText("Wrong ! Please log in again!");
l3.setFont(f1);
d.show();}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -