|
@ -47,6 +47,7 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
JButton loeschen; |
|
|
JButton loeschen; |
|
|
JButton exit; |
|
|
JButton exit; |
|
|
JButton hinzufuegen; |
|
|
JButton hinzufuegen; |
|
|
|
|
|
JButton erspartesLoeschen; |
|
|
public static JLabel budgetDispaly; |
|
|
public static JLabel budgetDispaly; |
|
|
public static JLabel expensesDisplay; |
|
|
public static JLabel expensesDisplay; |
|
|
public static JLabel balanceDisplay; |
|
|
public static JLabel balanceDisplay; |
|
@ -212,9 +213,14 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
contentPane.add(savingsDisplay); |
|
|
contentPane.add(savingsDisplay); |
|
|
|
|
|
|
|
|
//Einfügen und hinzufügen des "Hinzufügen" Buttons |
|
|
//Einfügen und hinzufügen des "Hinzufügen" Buttons |
|
|
this.hinzufuegen = new JButton("Hinzuf\\u00fcgen"); |
|
|
|
|
|
hinzufuegen.setBounds(660, 126, 89, 23); |
|
|
|
|
|
|
|
|
this.hinzufuegen = new JButton("Hinzuf\u00fcgen"); |
|
|
|
|
|
hinzufuegen.setBounds(660, 126, 100, 23); |
|
|
contentPane.add(hinzufuegen); |
|
|
contentPane.add(hinzufuegen); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen und hinzufügen des "Erspartes löschen" Buttons |
|
|
|
|
|
this.erspartesLoeschen = new JButton("Erspartes L\u00F6schen"); |
|
|
|
|
|
erspartesLoeschen.setBounds(660, 160, 150, 23); |
|
|
|
|
|
contentPane.add(erspartesLoeschen); |
|
|
|
|
|
|
|
|
//Einfügen des Textfeldes für die Beschreibung der Ausgabe |
|
|
//Einfügen des Textfeldes für die Beschreibung der Ausgabe |
|
|
textExpensesName = new JTextField(); |
|
|
textExpensesName = new JTextField(); |
|
@ -272,51 +278,67 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
loeschen.addActionListener(this); |
|
|
loeschen.addActionListener(this); |
|
|
exit.addActionListener(this); |
|
|
exit.addActionListener(this); |
|
|
hinzufuegen.addActionListener(this); |
|
|
hinzufuegen.addActionListener(this); |
|
|
|
|
|
erspartesLoeschen.addActionListener(this); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent ae) { |
|
|
public void actionPerformed(ActionEvent ae) { |
|
|
try { |
|
|
|
|
|
budget = Double.parseDouble(text1.getText()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
showMessageDialog(null, "Sie müssen ihr Budget eingeben!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ae.getSource() == this.exit) { |
|
|
if (ae.getSource() == this.exit) { |
|
|
exitButton(); |
|
|
exitButton(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ae.getSource() == this.loeschen) { |
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.loeschen) { |
|
|
leeren(); |
|
|
leeren(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if(ae.getSource() == this.erspartesLoeschen) { |
|
|
|
|
|
loescheErspartes(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ae.getSource() == this.senden && (text1 != null && text2 != null)) { |
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.senden && (text1 != null && text2 != null)) { |
|
|
|
|
|
try { |
|
|
|
|
|
budget = Double.parseDouble(text1.getText()); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception e) { |
|
|
|
|
|
showMessageDialog(null, "Sie müssen ihr Budget eingeben!"); |
|
|
|
|
|
} |
|
|
budgetDispaly.setText(setBudgetView()); |
|
|
budgetDispaly.setText(setBudgetView()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ae.getSource() == this.berechne && (text1 != null && text2 != null)) { |
|
|
|
|
|
DefaultTableModel tab = (DefaultTableModel) myTable.getModel(); |
|
|
|
|
|
tab.addRow(new Object[] { (textExpensesName.getText()), Double.parseDouble(text2.getText()) }); |
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.berechne && (text1 != null && text2 != null)) { |
|
|
|
|
|
try { |
|
|
|
|
|
DefaultTableModel tab = (DefaultTableModel) myTable.getModel(); |
|
|
|
|
|
tab.addRow(new Object[] { (textExpensesName.getText()), Double.parseDouble(text2.getText()) }); |
|
|
|
|
|
|
|
|
|
|
|
balance -= Double.parseDouble(text2.getText()); |
|
|
|
|
|
expenses += Double.parseDouble(text2.getText()); |
|
|
|
|
|
expensesDisplay.setText(setExpensesView()); |
|
|
|
|
|
balanceDisplay.setText(setBalanceView()); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception e) { |
|
|
|
|
|
showMessageDialog(null, "Sie müssen ihre Ausgabe eingeben!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
balance -= Double.parseDouble(text2.getText()); |
|
|
|
|
|
expenses += Double.parseDouble(text2.getText()); |
|
|
|
|
|
expensesDisplay.setText(setExpensesView()); |
|
|
|
|
|
balanceDisplay.setText(setBalanceView()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ae.getSource() == this.hinzufuegen) { |
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.hinzufuegen) { |
|
|
erspartesHinzufuegen(); |
|
|
erspartesHinzufuegen(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void loescheErspartes() { |
|
|
|
|
|
erspartes = 0.0; |
|
|
|
|
|
savingsDisplay.setText("0.0 \u20AC"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void erspartesHinzufuegen() { |
|
|
private void erspartesHinzufuegen() { |
|
|
try { |
|
|
|
|
|
erspartes += (budget - expenses); |
|
|
erspartes += (budget - expenses); |
|
|
budget = 0.0; |
|
|
budget = 0.0; |
|
|
expenses = 0.0; |
|
|
expenses = 0.0; |
|
@ -326,14 +348,9 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
budgetDispaly.setText("0.0 \u20AC"); |
|
|
budgetDispaly.setText("0.0 \u20AC"); |
|
|
expensesDisplay.setText("0.0 \u20AC"); |
|
|
expensesDisplay.setText("0.0 \u20AC"); |
|
|
balanceDisplay.setText("0.0 \u20AC"); |
|
|
balanceDisplay.setText("0.0 \u20AC"); |
|
|
savingsDisplay.setText(Double.toString(erspartes)); |
|
|
|
|
|
|
|
|
savingsDisplay.setText(Double.toString(erspartes) + " \u20AC"); |
|
|
textExpensesName.setText(null); |
|
|
textExpensesName.setText(null); |
|
|
((DefaultTableModel) myTable.getModel()).setRowCount(0); |
|
|
((DefaultTableModel) myTable.getModel()).setRowCount(0); |
|
|
} catch (Exception e) { |
|
|
|
|
|
showMessageDialog(null, "Sie müssen ihr Budget und ihre Ausgaben eingeben!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void exitButton() { |
|
|
public static void exitButton() { |
|
|