|
|
@ -6,6 +6,8 @@ import java.awt.Font; |
|
|
|
import java.awt.Image; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyListener; |
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JPanel; |
|
|
@ -19,7 +21,7 @@ import javax.swing.JOptionPane; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
public class LoginFrame extends JFrame implements ActionListener { |
|
|
|
public class LoginFrame extends JFrame implements ActionListener, KeyListener { |
|
|
|
|
|
|
|
public JPanel contentPane; |
|
|
|
public static JPasswordField passwordField; |
|
|
@ -70,10 +72,23 @@ public class LoginFrame extends JFrame implements ActionListener { |
|
|
|
loginHauptImage.setIcon(new ImageIcon(image2)); |
|
|
|
loginHauptImage.setFont(new Font("Tahoma", Font.BOLD, 13)); |
|
|
|
contentPane.add(loginHauptImage); |
|
|
|
|
|
|
|
JLabel F5_ExitLabel = new JLabel("F5: exit"); |
|
|
|
F5_ExitLabel.setFont(new Font("Tahoma", Font.BOLD, 11)); |
|
|
|
F5_ExitLabel.setBounds(342, 237, 82, 14); |
|
|
|
contentPane.add(F5_ExitLabel); |
|
|
|
|
|
|
|
JLabel entfLeerenLabel = new JLabel("Entf: Leeren\r\n"); |
|
|
|
entfLeerenLabel.setFont(new Font("Tahoma", Font.BOLD, 11)); |
|
|
|
entfLeerenLabel.setBounds(342, 223, 82, 14); |
|
|
|
contentPane.add(entfLeerenLabel); |
|
|
|
|
|
|
|
this.anmelden.addActionListener(this); |
|
|
|
passwordField.addActionListener(this); |
|
|
|
benutzername.addActionListener(this); |
|
|
|
this.anmelden.addKeyListener(this); |
|
|
|
benutzername.addKeyListener(this); |
|
|
|
passwordField.addKeyListener(this); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -83,8 +98,8 @@ public class LoginFrame extends JFrame implements ActionListener { |
|
|
|
&& (benutzername.getText().length() == 0 || passwordField.getText().length() == 0)) { |
|
|
|
JOptionPane.showMessageDialog(anmelden, "Bitte geben Sie die richtigen Daten ein!"); |
|
|
|
} |
|
|
|
if (ae.getSource() == this.anmelden && benutzername.getText().length() > 0 |
|
|
|
&& passwordField.getText().length() > 0) { |
|
|
|
if (ae.getSource() == this.anmelden && benutzername.getText() != setBenutzername("admin") |
|
|
|
&& passwordField.getText() != setPassword("admin")) { |
|
|
|
MeinGui run = new MeinGui(); |
|
|
|
run.setVisible(true); |
|
|
|
|
|
|
@ -92,13 +107,48 @@ public class LoginFrame extends JFrame implements ActionListener { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static String setBenutzername() { |
|
|
|
String result = String.valueOf(benutzername); |
|
|
|
return result; |
|
|
|
protected static String setBenutzername(String benutzername) { |
|
|
|
return benutzername; |
|
|
|
} |
|
|
|
|
|
|
|
public static String setPassword() { |
|
|
|
String result = String.valueOf(benutzername); |
|
|
|
return result; |
|
|
|
protected static String setPassword(String password) { |
|
|
|
return password; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void keyTyped(KeyEvent e) { |
|
|
|
// TODO Auto-generated method stub |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
if (benutzername.getText().contentEquals(setBenutzername("admin")) |
|
|
|
&& passwordField.getText().equals(setPassword("admin"))) { |
|
|
|
MeinGui run = new MeinGui(); |
|
|
|
run.setVisible(true); |
|
|
|
} else { |
|
|
|
JOptionPane.showMessageDialog(this.anmelden, "Bitte geben Sie die richtigen Daten ein!"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_F5) { |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_DELETE) { |
|
|
|
benutzername.setText(benutzernameUndPasswordLeeren()); |
|
|
|
passwordField.setText(benutzernameUndPasswordLeeren()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
// TODO Auto-generated method stub |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static String benutzernameUndPasswordLeeren() { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |