import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jvnet.substance.skin.SubstanceCremeLookAndFeel;
public class Login extends JFrame implements WindowListener, ActionListener, KeyListener {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JTextField jTextField = null;
private JPasswordField jPasswordField = null;
private Connection connection; // @jve:decl-index=0:
private Statement stmt;
private String username;
private int flag = 0;
/**
- This is the default constructor
*/
public Login() {
super();
try {
UIManager.setLookAndFeel(new SubstanceCremeLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
initialize();
Dimension screen = getToolkit().getScreenSize(); // 得到屏幕尺寸
// pack(); //窗口适应组件尺寸
setLocation((screen.width - getWidth()) / 2, (screen.height - getHeight()) / 2);// 使窗口出现在屏幕中间
this.setResizable(false);// 不可缩放~~
this.addWindowListener(this);
connection = DBUtil.getlink();
try {
stmt = connection.createStatement();
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} // 链接数据库
}
/**
-
This method initializes this
-
@return void
*/
private void initialize() {
// 登录窗口大小
this.setSize(500, 308);
this.setContentPane(getJContentPane());
this.setTitle(“欢迎登录教材管理系统”);
}