1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
| package client;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JDesktopPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.awt.Rectangle;
public class Login extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JDesktopPane jDesktopPane = null;
private JLabel jLabelLogin = null;
private JLabel jLabelPassword = null;
public JTextField jTextFieldLogin = null;
public JButton jButtonLogin = null;
private boolean clickOnLogIn = false;
private boolean clickOnCreateAccount = false;
public JPasswordField jPasswordField = null;
private ImageIcon loginIcon;
private JButton jButtonCreateAccount = null;
public Login() {
super();
initialize();
}
private void initialize() {
loginIcon = new ImageIcon("Icons/login.gif");
this.setIconImage(loginIcon.getImage());
this.setResizable(false);
this.setSize(244, 209);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width/2 - this.getWidth()/2, dim.height/2 - this.getHeight()/2);
this.setBackground(java.awt.Color.white);
this.setContentPane(getJContentPane());
this.setTitle("Log In");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
public void windowOpened(java.awt.event.WindowEvent e) {
jTextFieldLogin.setFocusable(true);
}
});
}
private JPanel getJContentPane() {
if (jContentPane == null)
{
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJDesktopPane(), BorderLayout.CENTER);
}
return jContentPane;
}
private JDesktopPane getJDesktopPane() {
if (jDesktopPane == null)
{
jLabelLogin = new JLabel();
jLabelLogin.setBounds(new Rectangle(23, 23, 67, 19));
jLabelLogin.setText("Login");
jLabelPassword = new JLabel();
jLabelPassword.setBounds(new Rectangle(23, 51, 66, 21));
jLabelPassword.setText("Password");
jDesktopPane = new JDesktopPane();
jDesktopPane.setBackground(SystemColor.control);
jDesktopPane.add(jLabelLogin, null);
jDesktopPane.add(jLabelPassword, null);
jDesktopPane.add(getJTextFieldLogin(), null);
jDesktopPane.add(getJPasswordField(), null);
jDesktopPane.add(getJButtonLogin(), null);
jDesktopPane.add(getJButtonCreateAccount(), null);
}
return jDesktopPane;
}
private JTextField getJTextFieldLogin() {
if (jTextFieldLogin == null)
{
jTextFieldLogin = new JTextField();
jTextFieldLogin.setBounds(new Rectangle(101, 22, 107, 21));
}
return jTextFieldLogin;
}
private JPasswordField getJPasswordField() {
if (jPasswordField == null)
{
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(101, 50, 107, 21));
}
return jPasswordField;
}
private JButton getJButtonLogin() {
if (jButtonLogin == null)
{
jButtonLogin = new JButton();
jButtonLogin.setBounds(new Rectangle(102, 82, 85, 28));
jButtonLogin.setText("Log In");
jButtonLogin.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent e) {
if(e.getKeyCode()== 32)
clickOnLogIn = true;
}
});
jButtonLogin.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent e) {
if(e.getKeyCode()== 10)
clickOnLogIn = true;
}
});
jButtonLogin.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
clickOnLogIn = true;
}
});
}
return jButtonLogin;
}
private JButton getJButtonCreateAccount() {
if (jButtonCreateAccount == null) {
jButtonCreateAccount = new JButton();
jButtonCreateAccount.setBounds(new Rectangle(56, 136, 124, 23));
jButtonCreateAccount.setText("Create Account");
jButtonCreateAccount.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
clickOnCreateAccount = true;
}
});
}
return jButtonCreateAccount;
}
public boolean getClickOnLogIn()
{
return clickOnLogIn;
}
public void setClickOnLogIn(boolean clickOnLogIn)
{
this.clickOnLogIn = clickOnLogIn;
}
public boolean getClickOnCreateAccount()
{
return clickOnCreateAccount;
}
public void setClickOnCreateAccount(boolean clickOnCreateAccount)
{
this.clickOnCreateAccount = clickOnCreateAccount;
}
} |
Partager