📄 login.jad
字号:
// Decompiled by DJ v3.5.5.77 Copyright 2003 Atanas Neshkov Date: 2008-1-13 18:39:33
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: Login.java
package com.vbank;
import com.vbank.admin.WorkBench;
import com.vbank.db.DBManager;
import com.vbank.operate.ServiceFrame;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.*;
public class Login extends JFrame
{
private JLabel getJLabel()
{
if(jLabel == null)
{
jLabel = new JLabel();
jLabel.setText(" login on");
jLabel.setFont(new Font("Dialog", 1, 18));
jLabel.setHorizontalAlignment(0);
jLabel.setBounds(new Rectangle(78, 23, 186, 18));
}
return jLabel;
}
private JTextField getNameField()
{
if(nameField == null)
{
nameField = new JTextField();
nameField.setBounds(new Rectangle(133, 97, 122, 22));
}
return nameField;
}
private JButton getJButton()
{
if(jButton == null)
{
jButton = new JButton();
jButton.setFont(new Font("Dialog", 1, 12));
jButton.setHorizontalTextPosition(0);
jButton.setLocation(new Point(63, 196));
jButton.setSize(new Dimension(67, 29));
jButton.setText("login");
jButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(jButton))
{
System.out.println("actionPerformed()");
String name = nameField.getText();
String pwd = passwordField.getText();
String isadmin = "n";
if(jRadioButton.isSelected())
isadmin = "y";
if(name != null && pwd != null)
{
closeLoginFrame();
int f = verifyUser(name, pwd, isadmin);
switch(f)
{
case -1:
reEnter();
break;
case 0: // '\0'
(new WorkBench(name, isadmin)).setVisible(true);
break;
case 1: // '\001'
(new ServiceFrame(name, isadmin)).setVisible(true);
break;
}
} else
{
reEnter();
}
}
}
final Login this$0;
{
this$0 = Login.this;
super();
}
});
}
return jButton;
}
private void closeLoginFrame()
{
dispose();
}
private int verifyUser(String name, String pwd, String isadmin)
{
int flag = -1;
if(name != "" && pwd != "")
{
String sql = (new StringBuilder("select * from operator where operateNum='")).append(name).append("' and operatePwd='").append(pwd).append("'and isadmin='").append(isadmin).append("'").toString();
DBManager.getConnection();
ResultSet rs = DBManager.executeSelect(sql);
try
{
if(rs.next())
if(rs.getString("isadmin").equalsIgnoreCase("y"))
flag = 0;
else
if(rs.getString("isadmin").equalsIgnoreCase("n"))
flag = 1;
}
catch(SQLException e1)
{
System.out.println("connection error");
e1.printStackTrace();
}
}
return flag;
}
private void reEnter()
{
repaint();
setVisible(true);
}
protected void paintComponent(Graphics g)
{
setVisible(false);
errorLabel.setText("Please enten your name or password!");
errorLabel.setVisible(true);
errorLabel.paintImmediately(errorLabel.getBounds());
super.paintComponents(g);
}
private JButton getJButton1()
{
if(jButton1 == null)
{
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(134, 197, 71, 29));
jButton1.setHorizontalTextPosition(2);
jButton1.setText("reset");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
nameField.setText("");
passwordField.setText("");
}
final Login this$0;
{
this$0 = Login.this;
super();
}
});
}
return jButton1;
}
private JButton getJButton2()
{
if(jButton2 == null)
{
jButton2 = new JButton();
jButton2.setBounds(new Rectangle(210, 197, 76, 29));
jButton2.setPreferredSize(new Dimension(65, 29));
jButton2.setText("cancel");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
closeLoginFrame();
}
final Login this$0;
{
this$0 = Login.this;
super();
}
});
}
return jButton2;
}
private JTextField getPasswordField()
{
if(passwordField == null)
{
passwordField = new JPasswordField();
passwordField.setBounds(new Rectangle(135, 137, 119, 22));
}
return passwordField;
}
private JRadioButton getJRadioButton()
{
if(jRadioButton == null)
{
jRadioButton = new JRadioButton();
jRadioButton.setBounds(new Rectangle(74, 171, 21, 21));
}
return jRadioButton;
}
private JRadioButton getJRadioButton1()
{
if(jRadioButton1 == null)
{
jRadioButton1 = new JRadioButton();
jRadioButton1.setBounds(new Rectangle(185, 172, 21, 21));
jRadioButton1.setSelected(true);
}
return jRadioButton1;
}
public static void main(String args[])
{
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
Login thisClass = new Login();
thisClass.setDefaultCloseOperation(3);
thisClass.setVisible(true);
}
});
}
public Login()
{
jContentPane = null;
jLabel = null;
jLabel1 = null;
nameField = null;
jLabel2 = null;
jButton = null;
jButton1 = null;
jButton2 = null;
passwordField = null;
errorLabel = null;
jRadioButton = null;
jLabel3 = null;
jRadioButton1 = null;
jLabel4 = null;
initialize();
}
private void initialize()
{
setSize(360, 289);
int w = Toolkit.getDefaultToolkit().getScreenSize().width;
int h = Toolkit.getDefaultToolkit().getScreenSize().height;
int x = (w - getSize().width) / 2;
int y = (h - getSize().height) / 2;
setLocation(x, y);
setContentPane(getJContentPane());
setTitle("Admin Login");
setVisible(true);
}
private JPanel getJContentPane()
{
if(jContentPane == null)
{
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(208, 174, 36, 15));
jLabel4.setText("other");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(99, 173, 36, 15));
jLabel3.setText("admin");
errorLabel = new JLabel();
errorLabel.setBounds(new Rectangle(78, 61, 163, 18));
errorLabel.setForeground(new Color(242, 1, 3));
errorLabel.setText("JLabel");
errorLabel.setVisible(false);
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(62, 138, 66, 18));
jLabel2.setHorizontalAlignment(0);
jLabel2.setText("password:");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(62, 98, 67, 18));
jLabel1.setHorizontalAlignment(0);
jLabel1.setText("account:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJLabel(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(getNameField(), null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJButton2(), null);
jContentPane.add(getPasswordField(), null);
jContentPane.add(errorLabel, null);
jContentPane.add(getJRadioButton(), null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJRadioButton1(), null);
jContentPane.add(jLabel4, null);
ButtonGroup bg = new ButtonGroup();
bg.add(getJRadioButton());
bg.add(getJRadioButton1());
}
return jContentPane;
}
private static final long serialVersionUID = 1L;
private JPanel jContentPane;
private JLabel jLabel;
private JLabel jLabel1;
private JTextField nameField;
private JLabel jLabel2;
private JButton jButton;
private JButton jButton1;
private JButton jButton2;
private JTextField passwordField;
private JLabel errorLabel;
private JRadioButton jRadioButton;
private JLabel jLabel3;
private JRadioButton jRadioButton1;
private JLabel jLabel4;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -