package dao; import java.awt.EventQueue; import javax.swing.JFrame; import java.awt.GridBagLayout; import java.awt.HeadlessException; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import javax.swing.JTextField; import java.awt.GridBagConstraints; import net.miginfocom.swing.MigLayout; import javax.swing.JButton; import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Cursor; import java.awt.FlowLayout; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JRadioButton; import javax.swing.JPasswordField; import javax.swing.JLabel; import javax.swing.JOptionPane; import java.awt.Font; import javax.swing.LayoutStyle.ComponentPlacement; import javax.swing.ImageIcon; import java.awt.event.ActionListener; import java.sql.SQLException; import java.awt.event.ActionEvent; import java.awt.Color; import java.awt.SystemColor; public class Login { private JFrame frame; private JTextField textField; private JPasswordField passwordField; public JFrame getFrame() { return frame; } /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { final Login window = new Login(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public Login() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame("符文之地英雄情报登录"); frame.setIconImage(Toolkit.getDefaultToolkit().getImage(Login.class.getResource("/LOLimage/game.png"))); frame.setBounds(100, 100, 587, 369); frame.setLocationRelativeTo(null);// 窗体居中 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //setUndecorated(true); /*Toolkit kit=Toolkit.getDefaultToolkit(); Image img=kit.getImage("/LOLimage/game.png"); Cursor mouse=kit.createCustomCursor(img, new Point(1,1), "stick"); frame.setCursor(mouse);*/ JButton btnNewButton = new JButton("\u767B\u5F55");//登录按钮 btnNewButton.setFont(new Font("微软雅黑", Font.BOLD, 22)); btnNewButton.setToolTipText("\u8BF7\u8BA4\u771F\u6838\u5BF9\u8D26\u53F7\u5BC6\u7801\uFF01"); btnNewButton.setForeground(Color.WHITE); btnNewButton.setBounds(179, 257, 98, 37); //btnNewButton.setBorderPainted(false);//不打印边框 //btnNewButton.setBorder(null);//除去边框 btnNewButton.setFocusPainted(false);//除去焦点的框 btnNewButton.setContentAreaFilled(false);//除去默认的背景填充 btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String tpass=new String(passwordField.getPassword()); Sqluser sq=new Sqluser(textField.getText(),tpass); try { if(sq.select()==5) { frame.setVisible(false); LOL1 l1=new LOL1(); l1.getFrame().setVisible(true); } else if(sq.select()==1) { JOptionPane.showMessageDialog(null,"召唤师不存在!"); textField.setText(null); passwordField.setText(null); } else if(sq.select()==2) { JOptionPane.showMessageDialog(null,"密码错误,请核对后重新登陆!"); textField.setText(null); passwordField.setText(null); } else if(sq.select()==3) { JOptionPane.showMessageDialog(null,"通行证不能为空!"); textField.setText(null); passwordField.setText(null); }else if(sq.select()==4) { JOptionPane.showMessageDialog(null,"密码不能为空!"); } } catch (HeadlessException | SQLException e1) { // TODO 自动生成的 catch 块 e1.printStackTrace(); } } }); JButton btnNewButton_1 = new JButton("\u6CE8\u518C");//注册按钮 btnNewButton_1.setFont(new Font("微软雅黑", Font.BOLD, 22)); btnNewButton_1.setForeground(Color.WHITE); btnNewButton_1.setToolTipText("\u52A0\u5165\u6211\u4EEC\uFF01"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Zhucec zhu=new Zhucec();//实例化注册页面 zhu.frame.setVisible(true); frame.setVisible(false); } }); btnNewButton_1.setBounds(309, 257, 89, 37); btnNewButton_1.setFocusPainted(false); btnNewButton_1.setContentAreaFilled(false);//除去默认的背景填充 textField = new JTextField();//账号框 textField.setFont(new Font("楷体", Font.BOLD, 19)); textField.setForeground(Color.WHITE); textField.setBackground(Color.WHITE); textField.setBounds(196, 132, 213, 31); textField.setColumns(10); textField.setOpaque(false); passwordField = new JPasswordField();//密码框 passwordField.setFont(new Font("宋体", Font.BOLD, 19)); passwordField.setForeground(Color.WHITE); passwordField.setBounds(196, 184, 213, 30); passwordField.setOpaque(false); JLabel lblNewLabel = new JLabel("\u901A\u884C\u8BC1\uFF1A"); lblNewLabel.setForeground(Color.WHITE); lblNewLabel.setBounds(101, 135, 84, 24); lblNewLabel.setFont(new Font("楷体", Font.BOLD, 20)); JLabel lblNewLabel_1 = new JLabel("\u5BC6 \u7801\uFF1A"); lblNewLabel_1.setForeground(Color.WHITE); lblNewLabel_1.setBounds(100, 187, 85, 24); lblNewLabel_1.setFont(new Font("楷体", Font.BOLD, 20)); JLabel lblNewLabel_2 = new JLabel(" ");//logo lblNewLabel_2.setBounds(207, 10, 170, 124); lblNewLabel_2.setIcon(new ImageIcon(Login.class.getResource("/LOLimage/login_logo.png"))); frame.getContentPane().setLayout(null); frame.getContentPane().add(btnNewButton); frame.getContentPane().add(btnNewButton_1); frame.getContentPane().add(lblNewLabel); frame.getContentPane().add(lblNewLabel_1); frame.getContentPane().add(textField); frame.getContentPane().add(passwordField); frame.getContentPane().add(lblNewLabel_2); JLabel lblNewLabel_3 = new JLabel("");//背景图 实例化背景label lblNewLabel_3.setIcon(new ImageIcon(Login.class.getResource("/LOLimage/gameground.png")));//label的图像接口 设置背景图 lblNewLabel_3.setBounds(0, -3, 579, 341); JButton btnNewButton_2 = new JButton("\u5FD8\u8BB0\u5BC6\u7801\uFF1F");//忘记密码 btnNewButton_2.setFont(new Font("华文楷体", Font.PLAIN, 16)); btnNewButton_2.setToolTipText("\u627E\u56DE\u5BC6\u7801\uFF01"); btnNewButton_2.setForeground(Color.WHITE); btnNewButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(e.getSource()==btnNewButton_2) { frame.setVisible(false); Wangji wj=new Wangji();//实例化忘记密码页面 wj.frame.setVisible(true); } } }); btnNewButton_2.setBounds(242, 224, 118, 23); btnNewButton_2.setFocusPainted(false);//除去焦点的框 btnNewButton_2.setContentAreaFilled(false);//除去默认的背景填充 frame.getContentPane().add(btnNewButton_2); frame.getContentPane().add(lblNewLabel_3);//背景图添加 } }
最近下载更多