用户登陆框以及身份验证源代码:import java.lang.*;
import java.awt.*;public class j2005220
{
private static j2005220 Application; myFrame1 Form1;
myFrame2 Form2;
myFrame3 Form3;
public static void main(String [] args)
{
Application=new j2005220();
Application.Form1=new myFrame1(Application);
Application.Form2=new myFrame2(Application); Application.Form1.setVisible(true);
}}import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class myFrame1 extends Frame
{
private j2005220 Application;
private myFrame1 Form1;
private myFrame2 Form2;
private myFrame3 Form3; Button B1;
Label L1;
Label L2;
TextField T1;
TextField T2;
public myFrame1(j2005220 app)
{
Application=app;
Form1=this; this.setLayout(null);
B1 = new Button("OK");
B1.setBounds(80,160,70,30);
B1.setBackground(Color.pink);
B1.addMouseListener(new myMouseListener());
this.add(B1);
L1=new Label("用户ID:");
L1.setBounds(20,80,50,30);
L1.setBackground(Color.orange);
this.add(L1);
L2=new Label("用户密码:");
L2.setBounds(20,120,60,30);
L2.setBackground(Color.orange);
this.add(L2);
T1=new TextField("");
T1.setBounds(80,80,130,30);
this.add(T1);
T2=new TextField("");
T2.setBounds(80,120,130,30);
T2.setEchoChar('*');
this.add(T2);
this.setBackground(Color.orange);
this.setBounds(200,100,250,220);
this.addWindowListener(new closej2005220());
this.setVisible(true);
}
class closej2005220 extends WindowAdapter
{
public void windowOpened(WindowEvent e)
{
Form2=Application.Form2; }
public void windowClosing(WindowEvent e) {
JOptionPane.showMessageDialog(null,"您确定要退出本程序吗?"); System.exit(0);
} }
class myMouseListener extends MouseAdapter
{ public void mouseClicked(MouseEvent e) {
if(e.getButton()==MouseEvent.BUTTON1)
{
String UserID = T1.getText();
String UserPswd=T2.getText(); if(T1.getText().equals("user1") && T2.getText().equals("user1"))
{
JOptionPane.showMessageDialog(null,"欢迎您的光临!");
Form2.setVisible(true);
T1.setText("");
T2.setText(""); }
else
{
JOptionPane.showMessageDialog(null,"请输入正确的帐号和密码!");
T1.setText("");
T2.setText(""); }
}
else
{
System.out.println("请按左键!");
} }
}}import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class myFrame2 extends Frame
{
private j2005220 Application;
private myFrame1 Form1;
private myFrame2 Form2;
private myFrame3 Form3;
Button B1,B2,B3,B4; public myFrame2(j2005220 app)
{
Application=app;
Form2=this; this.setLayout(null);
B1=new Button("查询用户信息");
B1.setBounds(75,40,100,30);
B1.setBackground(Color.pink);
this.add(B1);
B2=new Button("修改用户密码");
B2.setBounds(75,80,100,30);
B2.setBackground(Color.pink);
B2.addActionListener(new yourActionListener());
this.add(B2);
B3=new Button("用户取款");
B3.setBounds(75,120,100,30);
B3.setBackground(Color.pink);
this.add(B3);
B4=new Button("退出系统");
B4.setBounds(75,160,100,30);
B4.setBackground(Color.pink);
this.add(B4);
this.setBounds(250,150,250,220);
this.setTitle("用户功能表:");
this.setBackground(Color.orange);
this.addWindowListener(new yourWindowAdapter());
}
class yourWindowAdapter extends WindowAdapter
{
public void windowOpened(WindowEvent e)
{
Form1=Application.Form1;
Form1.setVisible(false); }
public void windowClosing(WindowEvent e)
{
Form2.setVisible(false);
Form1.setVisible(true); }
public void windowActivated(WindowEvent e){
if(Form3==null)
Form3 = Application.Form3;
}
}
class yourActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==B2)
{
if(Form3==null)
{
Application.Form3=new myFrame3(Application);
Form3=Application.Form3;
import java.awt.*;public class j2005220
{
private static j2005220 Application; myFrame1 Form1;
myFrame2 Form2;
myFrame3 Form3;
public static void main(String [] args)
{
Application=new j2005220();
Application.Form1=new myFrame1(Application);
Application.Form2=new myFrame2(Application); Application.Form1.setVisible(true);
}}import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class myFrame1 extends Frame
{
private j2005220 Application;
private myFrame1 Form1;
private myFrame2 Form2;
private myFrame3 Form3; Button B1;
Label L1;
Label L2;
TextField T1;
TextField T2;
public myFrame1(j2005220 app)
{
Application=app;
Form1=this; this.setLayout(null);
B1 = new Button("OK");
B1.setBounds(80,160,70,30);
B1.setBackground(Color.pink);
B1.addMouseListener(new myMouseListener());
this.add(B1);
L1=new Label("用户ID:");
L1.setBounds(20,80,50,30);
L1.setBackground(Color.orange);
this.add(L1);
L2=new Label("用户密码:");
L2.setBounds(20,120,60,30);
L2.setBackground(Color.orange);
this.add(L2);
T1=new TextField("");
T1.setBounds(80,80,130,30);
this.add(T1);
T2=new TextField("");
T2.setBounds(80,120,130,30);
T2.setEchoChar('*');
this.add(T2);
this.setBackground(Color.orange);
this.setBounds(200,100,250,220);
this.addWindowListener(new closej2005220());
this.setVisible(true);
}
class closej2005220 extends WindowAdapter
{
public void windowOpened(WindowEvent e)
{
Form2=Application.Form2; }
public void windowClosing(WindowEvent e) {
JOptionPane.showMessageDialog(null,"您确定要退出本程序吗?"); System.exit(0);
} }
class myMouseListener extends MouseAdapter
{ public void mouseClicked(MouseEvent e) {
if(e.getButton()==MouseEvent.BUTTON1)
{
String UserID = T1.getText();
String UserPswd=T2.getText(); if(T1.getText().equals("user1") && T2.getText().equals("user1"))
{
JOptionPane.showMessageDialog(null,"欢迎您的光临!");
Form2.setVisible(true);
T1.setText("");
T2.setText(""); }
else
{
JOptionPane.showMessageDialog(null,"请输入正确的帐号和密码!");
T1.setText("");
T2.setText(""); }
}
else
{
System.out.println("请按左键!");
} }
}}import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class myFrame2 extends Frame
{
private j2005220 Application;
private myFrame1 Form1;
private myFrame2 Form2;
private myFrame3 Form3;
Button B1,B2,B3,B4; public myFrame2(j2005220 app)
{
Application=app;
Form2=this; this.setLayout(null);
B1=new Button("查询用户信息");
B1.setBounds(75,40,100,30);
B1.setBackground(Color.pink);
this.add(B1);
B2=new Button("修改用户密码");
B2.setBounds(75,80,100,30);
B2.setBackground(Color.pink);
B2.addActionListener(new yourActionListener());
this.add(B2);
B3=new Button("用户取款");
B3.setBounds(75,120,100,30);
B3.setBackground(Color.pink);
this.add(B3);
B4=new Button("退出系统");
B4.setBounds(75,160,100,30);
B4.setBackground(Color.pink);
this.add(B4);
this.setBounds(250,150,250,220);
this.setTitle("用户功能表:");
this.setBackground(Color.orange);
this.addWindowListener(new yourWindowAdapter());
}
class yourWindowAdapter extends WindowAdapter
{
public void windowOpened(WindowEvent e)
{
Form1=Application.Form1;
Form1.setVisible(false); }
public void windowClosing(WindowEvent e)
{
Form2.setVisible(false);
Form1.setVisible(true); }
public void windowActivated(WindowEvent e){
if(Form3==null)
Form3 = Application.Form3;
}
}
class yourActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==B2)
{
if(Form3==null)
{
Application.Form3=new myFrame3(Application);
Form3=Application.Form3;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货