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
| public class authentification extends JFrame{
paneau pan;
JTextField login;
JLabel ok ;
JPasswordField password;
public static void main(String[] args) {
authentification at=new authentification();
at.setVisible(true);
}
public authentification(){
try {
Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
setLocation(((d.width)/2)-300,((d.height)/2)-152);
setSize(600,304);
setLayout(null);
setTitle("login");
setContentPane(new paneau());
} catch (Exception e) {
// TODO: handle exception
}
}
class paneau extends JPanel{
public paneau(){
super();
}
public void paintComponent(Graphics g){
super.paintComponent(g);
try {
BufferedImage image = ImageIO.read(new File("login.jpg"));
g.drawImage(image, 0, 0, null);
Font f=new Font("Arial",Font.BOLD+Font.ITALIC,15);
ImageIcon ico=new ImageIcon("ok.png");
login=new JTextField(15);
login.setBorder(BorderFactory.createLineBorder(Color.black));
login.setFont(f);
login.setForeground(Color.black);
login.setBackground(Color.DARK_GRAY);
login.setBounds(175, 87,136,20);
password=new JPasswordField(15);
password.setBorder(BorderFactory.createLineBorder(Color.black));
password.setBounds(175, 127,136,20);
password.setForeground(Color.black);
password.setBackground(Color.DARK_GRAY);
password.setFont(f);
ok=new JLabel(ico);
ok.setBounds(320, 165,24,23);
ok.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
add(login);
add(ok);
add(password);
} catch (IOException e) {
e.printStackTrace();
}
}
}
} |
Partager