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
|
package GUI;
import java.awt.EventQueue;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import auth.Ldap;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
import java.awt.Color;
@SuppressWarnings("serial")
public class LoginWindow extends JFrame {
private JPanel contentPane;
private JTextField username;
private JPasswordField pass;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
//Aufruf und Anzeige des Login Fensters
LoginWindow frame = new LoginWindow();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public LoginWindow() {
//Fenster darf nicht vergrößert werden
setResizable(false);
try {
//Setzt das Look and Feel auf System
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Titel des Fensters setzen
setTitle("Dozentenmodul");
//Aktion die beim Schließen durchgeführt werden soll
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Größe des Fensters definieren
setBounds(100, 100, 300, 300);
//Erzeugen eines Panels
contentPane = new JPanel();
//Hintergrund Farbe des Panels setzen
contentPane.setBackground(Color.WHITE);
//Rahmen des Fensters setzen
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
//Layout setzen
contentPane.setLayout(null);
//Label für das Logo erzeugen
JLabel imgLabel = new JLabel();
//Größe und Position des Logos festelegen
imgLabel.setBounds(10, 11, 270, 64);
//Pfadangabe des Logos
ImageIcon icon = new ImageIcon("img/Logo_bwLehrpool.png","Logo");
//Skalierung des Logos
Image scaled=icon.getImage().getScaledInstance(270, 64, 0);
imgLabel.setIcon(new ImageIcon(scaled));
//Hinzufügen des Logos in das Fenster
contentPane.add(imgLabel);
//Erzeugen und Hinzufügen des Labels
JLabel LabelUser = new JLabel("bwIDM-Benutzername:");
LabelUser.setBounds(10, 86, 134, 20);
contentPane.add(LabelUser);
//Erzeugen und Hinzufügen des Textfeldes
username = new JTextField();
username.setBounds(154, 86, 125, 20);
contentPane.add(username);
username.setColumns(10);
//Erzeugen und Hinzufügen des Labels
JLabel LabelPass = new JLabel("bwIDM-Passwort:");
LabelPass.setBounds(10, 117, 134, 20);
contentPane.add(LabelPass);
//Erzeugen, Hinzufügen und definierung der Aktion des Buttons
JButton BtnLogin = new JButton("Login");
BtnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//Aufruf der Ldap Klasse, welche die Ldap überprüfung vornimmt
Ldap check=new Ldap();
boolean login=check.LdapAuth(username.getText(), new String(pass.getPassword()));
if(login==true)
{
//Erstellen einer Instanz der Aktionsauswahl
ActionChooser ac=new ActionChooser();
ac.setVisible(true);
//Schließen des Fensters nach erfolgreichen Login
dispose();
}
}
});
BtnLogin.setBounds(10, 179, 134, 23);
contentPane.add(BtnLogin);
//Erzeugen und Hinzufügen des Passwortfeldes
pass = new JPasswordField();
pass.setBounds(154, 117, 125, 20);
contentPane.add(pass);
}
}
|