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
| package client;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.*;
import java.io.IOException;
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 JPanel jContentPane = null;
private JDesktopPane jDesktopPane = null;
private JLabel jLabelLogin = null;
private JLabel jLabelPassword = null;
private JLabel jLabelIP = null;
public JTextField jTextFieldLogin = null;
public JTextField jTextFieldIP = null;
public JButton jButtonLogin = null;
public boolean clickOnLogIn = false;
public JPasswordField jPasswordField = null;
public ImageIcon loginIcon;
public Login() {
super();
initialize();
}
private void initialize() {
WindowListener stop = new WindowAdapter() {
public void windowClosing(WindowEvent e){ System.exit(0);}
};
addWindowListener(stop);
loginIcon = new ImageIcon("Icons/login.gif");
this.setIconImage(loginIcon.getImage());
this.setResizable(false);
this.setSize(244, 196);
this.setBackground(java.awt.Color.white);
this.setContentPane(getJContentPane());
this.setTitle("Log In");
this.setVisible(true);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width/2 - this.getWidth()/2, dim.height/2 - this.getHeight()/2);
}
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");
jLabelIP = new JLabel();
jLabelIP.setBounds(new Rectangle(23, 79, 67, 19));
jLabelIP.setText("IP");
jDesktopPane = new JDesktopPane();
jDesktopPane.setBackground(SystemColor.control);
jDesktopPane.add(jLabelLogin, null);
jDesktopPane.add(jLabelPassword, null);
jDesktopPane.add(jLabelIP, null);
jDesktopPane.add(getJTextFieldLogin(), null);
jDesktopPane.add(getJPasswordField(), null);
jDesktopPane.add(getJTextFieldIP(), null);
jDesktopPane.add(getJButtonLogin(), null);
}
return jDesktopPane;
}
private JTextField getJTextFieldLogin() {
if (jTextFieldLogin == null)
{
jTextFieldLogin = new JTextField();
jTextFieldLogin.setBounds(new Rectangle(101, 22, 107, 21));
}
return jTextFieldLogin;
}
private JTextField getJTextFieldIP() {
if (jTextFieldIP == null)
{
jTextFieldIP = new JTextField();
jTextFieldIP.setBounds(new Rectangle(101, 78, 107, 21));
}
return jTextFieldIP;
}
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(77, 115, 85, 21));
jButtonLogin.setText("Log In");
jButtonLogin.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
clickOnLogIn=true;
}
});
jButtonLogin.addKeyListener(new KeyAdapter() {
public void KeyPressed(KeyEvent e) {
if (e.getKeyCode()== KeyEvent.VK_ENTER)
clickOnLogIn=true;
}
});
}
return jButtonLogin;
}
} // @jve:decl-index=0:visual-constraint="10,10" |
Partager