|
|
@ -2,71 +2,103 @@ package MeinBudgetView; |
|
|
|
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.EventQueue; |
|
|
|
import java.awt.Font; |
|
|
|
import java.awt.Image; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.border.EmptyBorder; |
|
|
|
import javax.swing.ImageIcon; |
|
|
|
import javax.swing.JButton; |
|
|
|
import javax.swing.JPasswordField; |
|
|
|
import javax.swing.JTextField; |
|
|
|
import javax.swing.JLabel; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
public class LoginFrame extends JFrame { |
|
|
|
|
|
|
|
private JPanel contentPane; |
|
|
|
private JPasswordField passwordField; |
|
|
|
private JTextField textField; |
|
|
|
|
|
|
|
/** |
|
|
|
* Launch the application. |
|
|
|
*/ |
|
|
|
public static void main(String[] args) { |
|
|
|
EventQueue.invokeLater(new Runnable() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
LoginFrame frame = new LoginFrame(); |
|
|
|
frame.setVisible(true); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
public class LoginFrame extends JFrame implements ActionListener { |
|
|
|
|
|
|
|
public JPanel contentPane; |
|
|
|
public static JPasswordField passwordField; |
|
|
|
public static JTextField benutzername; |
|
|
|
public JButton anmelden; |
|
|
|
|
|
|
|
/** |
|
|
|
* Create the frame. |
|
|
|
*/ |
|
|
|
public LoginFrame() { |
|
|
|
setTitle("Anmelden"); |
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
setBounds(100, 100, 450, 300); |
|
|
|
contentPane = new JPanel(); |
|
|
|
contentPane.setBackground(Color.WHITE); |
|
|
|
contentPane.setBackground(Color.orange); |
|
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
|
|
setContentPane(contentPane); |
|
|
|
contentPane.setLayout(null); |
|
|
|
|
|
|
|
JButton anmelden = new JButton("Anmelden"); |
|
|
|
|
|
|
|
anmelden = new JButton("Anmelden"); |
|
|
|
anmelden.setBounds(182, 168, 97, 23); |
|
|
|
contentPane.add(anmelden); |
|
|
|
|
|
|
|
|
|
|
|
passwordField = new JPasswordField(); |
|
|
|
passwordField.setBounds(147, 137, 132, 20); |
|
|
|
contentPane.add(passwordField); |
|
|
|
|
|
|
|
textField = new JTextField(); |
|
|
|
textField.setBounds(147, 106, 132, 20); |
|
|
|
contentPane.add(textField); |
|
|
|
textField.setColumns(10); |
|
|
|
|
|
|
|
JLabel lblNewLabel = new JLabel("Benutzername:"); |
|
|
|
lblNewLabel.setBounds(48, 106, 89, 20); |
|
|
|
contentPane.add(lblNewLabel); |
|
|
|
|
|
|
|
JLabel lblNewLabel_1 = new JLabel("Password: "); |
|
|
|
lblNewLabel_1.setBounds(61, 140, 76, 14); |
|
|
|
contentPane.add(lblNewLabel_1); |
|
|
|
|
|
|
|
benutzername = new JTextField(); |
|
|
|
benutzername.setBounds(147, 106, 132, 20); |
|
|
|
contentPane.add(benutzername); |
|
|
|
benutzername.setColumns(10); |
|
|
|
|
|
|
|
JLabel labaelBenutzername = new JLabel("Benutzername:"); |
|
|
|
labaelBenutzername.setBounds(48, 106, 89, 20); |
|
|
|
contentPane.add(labaelBenutzername); |
|
|
|
|
|
|
|
JLabel labelPassword = new JLabel("Password: "); |
|
|
|
labelPassword.setBounds(61, 140, 76, 14); |
|
|
|
contentPane.add(labelPassword); |
|
|
|
|
|
|
|
JLabel loginImage = new JLabel(""); |
|
|
|
loginImage.setBounds(313, 106, 56, 51); |
|
|
|
Image image1 = new ImageIcon(this.getClass().getResource("/login-icon.png")).getImage(); |
|
|
|
loginImage.setIcon(new ImageIcon(image1)); |
|
|
|
loginImage.setFont(new Font("Tahoma", Font.BOLD, 13)); |
|
|
|
contentPane.add(loginImage); |
|
|
|
|
|
|
|
JLabel loginHauptImage = new JLabel(""); |
|
|
|
loginHauptImage.setBounds(10, 11, 56, 51); |
|
|
|
Image image2 = new ImageIcon(this.getClass().getResource("/budgetapp.png")).getImage(); |
|
|
|
loginHauptImage.setIcon(new ImageIcon(image2)); |
|
|
|
loginHauptImage.setFont(new Font("Tahoma", Font.BOLD, 13)); |
|
|
|
contentPane.add(loginHauptImage); |
|
|
|
|
|
|
|
this.anmelden.addActionListener(this); |
|
|
|
passwordField.addActionListener(this); |
|
|
|
benutzername.addActionListener(this); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent ae) { |
|
|
|
|
|
|
|
if (ae.getSource() == this.anmelden |
|
|
|
&& (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) { |
|
|
|
MeinGui run = new MeinGui(); |
|
|
|
run.setVisible(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static String setBenutzername() { |
|
|
|
String result = String.valueOf(benutzername); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public static String setPassword() { |
|
|
|
String result = String.valueOf(benutzername); |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |