diff --git a/Budget Projekt/bin/MeinBudgetView/LoginFrame.class b/Budget Projekt/bin/MeinBudgetView/LoginFrame.class index 2ea4074..b56d6db 100644 Binary files a/Budget Projekt/bin/MeinBudgetView/LoginFrame.class and b/Budget Projekt/bin/MeinBudgetView/LoginFrame.class differ diff --git a/Budget Projekt/bin/MeinBudgetView/MyTest.class b/Budget Projekt/bin/MeinBudgetView/MyTest.class index 2903a50..d118b03 100644 Binary files a/Budget Projekt/bin/MeinBudgetView/MyTest.class and b/Budget Projekt/bin/MeinBudgetView/MyTest.class differ diff --git a/Budget Projekt/src/MeinBudgetView/LoginFrame.java b/Budget Projekt/src/MeinBudgetView/LoginFrame.java index 57d0027..a61a073 100644 --- a/Budget Projekt/src/MeinBudgetView/LoginFrame.java +++ b/Budget Projekt/src/MeinBudgetView/LoginFrame.java @@ -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 ""; } } diff --git a/Budget Projekt/src/MeinBudgetView/MeinGui.java b/Budget Projekt/src/MeinBudgetView/MeinGui.java index 3e90678..ad03c89 100644 --- a/Budget Projekt/src/MeinBudgetView/MeinGui.java +++ b/Budget Projekt/src/MeinBudgetView/MeinGui.java @@ -9,6 +9,8 @@ import javax.swing.JTextField; 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.ImageIcon; import javax.swing.JButton; @@ -29,7 +31,7 @@ import javax.swing.border.BevelBorder; import javax.swing.border.TitledBorder; import javax.swing.UIManager; -public class MeinGui extends JFrame implements ActionListener { +public class MeinGui extends JFrame implements ActionListener, KeyListener { private JPanel contentPane; public static JTextField text1; @@ -208,11 +210,17 @@ public class MeinGui extends JFrame implements ActionListener { scrollPane_1.setViewportView(myTable); text1.addActionListener(this); + text1.addKeyListener(this); text2.addActionListener(this); + text2.addKeyListener(this); senden.addActionListener(this); + senden.addKeyListener(this); berechne.addActionListener(this); + berechne.addKeyListener(this); loeschen.addActionListener(this); + loeschen.addKeyListener(this); exit.addActionListener(this); + exit.addKeyListener(this); } @@ -249,12 +257,12 @@ public class MeinGui extends JFrame implements ActionListener { } public static void leeren() { - text1.setText(null); - text2.setText(null); - budgetDispaly.setText(null); - expensesDisplay.setText(null); - balanceDisplay.setText(null); - textExpensesName.setText(null); + text1.setText(""); + text2.setText(""); + budgetDispaly.setText("0.0 €"); + expensesDisplay.setText("0.0 €"); + balanceDisplay.setText("0.0 €"); + textExpensesName.setText(""); ((DefaultTableModel) myTable.getModel()).setRowCount(0); } @@ -273,4 +281,26 @@ public class MeinGui extends JFrame implements ActionListener { return result; } + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_DELETE) { + leeren(); + } + if (e.getKeyCode() == KeyEvent.VK_F5) { + exitButton(); + } + + } + + @Override + public void keyReleased(KeyEvent e) { + // TODO Auto-generated method stub + + } + } diff --git a/Budget Projekt/src/MeinBudgetView/MyTest.java b/Budget Projekt/src/MeinBudgetView/MyTest.java index a4a5e72..9542243 100644 --- a/Budget Projekt/src/MeinBudgetView/MyTest.java +++ b/Budget Projekt/src/MeinBudgetView/MyTest.java @@ -1,5 +1,6 @@ package MeinBudgetView; +import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; @@ -48,19 +49,35 @@ class MyTest { @Test public void testSetBenutzername() { - String result = String.valueOf(LoginFrame.benutzername); - assertEquals(result, LoginFrame.setBenutzername()); - assertNotEquals(result + " ", LoginFrame.setBenutzername()); - assertNotEquals(null, LoginFrame.setBenutzername()); + + assertEquals("admin", LoginFrame.setBenutzername("admin")); + assertEquals("ADMIN", LoginFrame.setBenutzername("ADMIN")); + assertNotEquals("Admin", LoginFrame.setBenutzername("")); + assertNotEquals("admin", LoginFrame.setBenutzername("Admin")); + assertNotEquals("", LoginFrame.setBenutzername("admin")); + assertEquals("ADMin".toUpperCase(), LoginFrame.setBenutzername("admin").toUpperCase()); } @Test public void testSetPassword() { - String result = String.valueOf(LoginFrame.passwordField); - assertEquals(result, LoginFrame.setPassword()); - assertNotEquals(result + " ", LoginFrame.setPassword()); - assertNotEquals(null, LoginFrame.setPassword()); + + assertEquals("password", LoginFrame.setBenutzername("password")); + assertEquals("PassWord", LoginFrame.setBenutzername("PassWord")); + assertNotEquals("password", LoginFrame.setBenutzername("")); + assertNotEquals("PASSWORD", LoginFrame.setBenutzername("password")); + assertNotEquals("", LoginFrame.setBenutzername("password")); + assertEquals("PaSSwOrd".toUpperCase(), LoginFrame.setBenutzername("passwoRd").toUpperCase()); + + } + + @Test + public void testSetLeeren() { + + assertEquals("", LoginFrame.benutzernameUndPasswordLeeren()); + assertNotEquals(" ", LoginFrame.benutzernameUndPasswordLeeren()); + assertNotEquals("".length() > 0, LoginFrame.benutzernameUndPasswordLeeren()); + assertNotEquals("" == null, LoginFrame.benutzernameUndPasswordLeeren()); } diff --git a/Command.txt b/Command.txt new file mode 100644 index 0000000..079746a --- /dev/null +++ b/Command.txt @@ -0,0 +1,7 @@ +Befehle: + +1)Benutzername: admin +2)Password: admin + +DELETE_Taste: Alle Einträge leeren +F5: Exit diff --git a/Hinweis El Boukhari.txt b/Hinweis El Boukhari.txt deleted file mode 100644 index ca25228..0000000 --- a/Hinweis El Boukhari.txt +++ /dev/null @@ -1,5 +0,0 @@ -Ich möchte hier darauf hinweisen, dass ich meistens von meinem git Bash(User: Adah Boukhari) pushen werde. - -Name: Mohamed El Boukhari -Matrikel-Nr: 344691 -fdlt3054 diff --git a/Namen und MatrNr.txt b/Namen und MatrNr.txt new file mode 100644 index 0000000..2750302 --- /dev/null +++ b/Namen und MatrNr.txt @@ -0,0 +1,4 @@ + +Name: Mohamed El Boukhari(User_MyGitBash:Adah Boukhari) +Matrikel-Nr: 344691 +fdlt3054