|
@ -30,165 +30,228 @@ import javax.swing.border.MatteBorder; |
|
|
import javax.swing.border.BevelBorder; |
|
|
import javax.swing.border.BevelBorder; |
|
|
import javax.swing.border.TitledBorder; |
|
|
import javax.swing.border.TitledBorder; |
|
|
import javax.swing.UIManager; |
|
|
import javax.swing.UIManager; |
|
|
|
|
|
import static javax.swing.JOptionPane.showMessageDialog; |
|
|
|
|
|
|
|
|
public class MeinGui extends JFrame implements ActionListener, KeyListener { |
|
|
public class MeinGui extends JFrame implements ActionListener, KeyListener { |
|
|
|
|
|
|
|
|
|
|
|
//Variablen Initialisierung |
|
|
private JPanel contentPane; |
|
|
private JPanel contentPane; |
|
|
public static JTextField text1; |
|
|
public static JTextField text1; |
|
|
public static JTextField text2; |
|
|
public static JTextField text2; |
|
|
JLabel labelBudgetImage; |
|
|
JLabel labelBudgetImage; |
|
|
JLabel labelExpensesImage; |
|
|
JLabel labelExpensesImage; |
|
|
JLabel labelBalancetImage; |
|
|
JLabel labelBalancetImage; |
|
|
|
|
|
JLabel labelSavingsImage; |
|
|
JLabel labelHauptImage; |
|
|
JLabel labelHauptImage; |
|
|
JButton senden; |
|
|
JButton senden; |
|
|
JButton berechne; |
|
|
JButton berechne; |
|
|
JLabel leeren; |
|
|
JLabel leeren; |
|
|
JButton loeschen; |
|
|
JButton loeschen; |
|
|
JButton exit; |
|
|
JButton exit; |
|
|
|
|
|
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; |
|
|
|
|
|
public static JLabel savingsDisplay; |
|
|
public static double budget; |
|
|
public static double budget; |
|
|
public static double expenses; |
|
|
public static double expenses; |
|
|
public static double balance; |
|
|
public static double balance; |
|
|
|
|
|
public static double erspartes; |
|
|
public static JTextField textExpensesName; |
|
|
public static JTextField textExpensesName; |
|
|
public static JLabel ausgabenName; |
|
|
public static JLabel ausgabenName; |
|
|
private static JLabel ausgabenBetrag; |
|
|
private static JLabel ausgabenBetrag; |
|
|
private static JLabel budgetBetrag; |
|
|
private static JLabel budgetBetrag; |
|
|
private static JTable myTable; |
|
|
private static JTable myTable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MeinGui() { |
|
|
public MeinGui() { |
|
|
|
|
|
|
|
|
|
|
|
//Erstellen der GUI |
|
|
setTitle("Budget"); |
|
|
setTitle("Budget"); |
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
setBounds(100, 100, 654, 368); |
|
|
|
|
|
|
|
|
setBounds(100, 100, 900, 368); |
|
|
contentPane = new JPanel(); |
|
|
contentPane = new JPanel(); |
|
|
contentPane.setBackground(Color.orange); |
|
|
contentPane.setBackground(Color.orange); |
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); |
|
|
setContentPane(contentPane); |
|
|
setContentPane(contentPane); |
|
|
contentPane.setLayout(null); |
|
|
contentPane.setLayout(null); |
|
|
|
|
|
|
|
|
|
|
|
//"Berechne" Button wird erstellt und hinzugefügt |
|
|
this.berechne = new JButton("Berechne"); |
|
|
this.berechne = new JButton("Berechne"); |
|
|
berechne.setBounds(78, 281, 110, 23); |
|
|
berechne.setBounds(78, 281, 110, 23); |
|
|
berechne.setToolTipText(""); |
|
|
berechne.setToolTipText(""); |
|
|
contentPane.add(berechne); |
|
|
contentPane.add(berechne); |
|
|
|
|
|
|
|
|
|
|
|
//"Senden" Button wird erstellt und hinzugefügt |
|
|
this.senden = new JButton("Senden"); |
|
|
this.senden = new JButton("Senden"); |
|
|
senden.setBounds(78, 126, 110, 23); |
|
|
senden.setBounds(78, 126, 110, 23); |
|
|
contentPane.add(senden); |
|
|
contentPane.add(senden); |
|
|
|
|
|
|
|
|
|
|
|
//Textfeld für das Budget wird erstellt und hinzugefügt |
|
|
text1 = new JTextField(); |
|
|
text1 = new JTextField(); |
|
|
text1.setBounds(60, 97, 128, 20); |
|
|
text1.setBounds(60, 97, 128, 20); |
|
|
contentPane.add(text1); |
|
|
contentPane.add(text1); |
|
|
text1.setColumns(10); |
|
|
text1.setColumns(10); |
|
|
|
|
|
|
|
|
|
|
|
//Textfeld für die Ausgaben wird erstellt und hinzugefügt |
|
|
text2 = new JTextField(); |
|
|
text2 = new JTextField(); |
|
|
text2.setBounds(60, 250, 128, 20); |
|
|
text2.setBounds(60, 250, 128, 20); |
|
|
contentPane.add(text2); |
|
|
contentPane.add(text2); |
|
|
text2.setColumns(10); |
|
|
text2.setColumns(10); |
|
|
|
|
|
|
|
|
|
|
|
//Logo der Applikation wird hinzugefügt |
|
|
labelHauptImage = new JLabel(""); |
|
|
labelHauptImage = new JLabel(""); |
|
|
labelHauptImage.setBounds(10, 0, 86, 61); |
|
|
labelHauptImage.setBounds(10, 0, 86, 61); |
|
|
Image image0 = new ImageIcon(this.getClass().getResource("/budgetapp.png")).getImage(); |
|
|
Image image0 = new ImageIcon(this.getClass().getResource("/budgetapp.png")).getImage(); |
|
|
labelHauptImage.setIcon(new ImageIcon(image0)); |
|
|
labelHauptImage.setIcon(new ImageIcon(image0)); |
|
|
|
|
|
|
|
|
labelHauptImage.setFont(new Font("Tahoma", Font.BOLD, 13)); |
|
|
labelHauptImage.setFont(new Font("Tahoma", Font.BOLD, 13)); |
|
|
contentPane.add(labelHauptImage); |
|
|
contentPane.add(labelHauptImage); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Textbeschreibung für das Eingabefeld "Budget" |
|
|
JLabel budgetEingeben = new JLabel("Budget eingeben"); |
|
|
JLabel budgetEingeben = new JLabel("Budget eingeben"); |
|
|
budgetEingeben.setBounds(10, 72, 110, 20); |
|
|
|
|
|
|
|
|
budgetEingeben.setBounds(10, 72, 130, 20); |
|
|
budgetEingeben.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
budgetEingeben.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
contentPane.add(budgetEingeben); |
|
|
contentPane.add(budgetEingeben); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der "Budget" Überschrift für die Berechnungstabelle |
|
|
JLabel labelBudget = new JLabel("Budget"); |
|
|
JLabel labelBudget = new JLabel("Budget"); |
|
|
labelBudget.setBounds(255, 8, 46, 14); |
|
|
labelBudget.setBounds(255, 8, 46, 14); |
|
|
contentPane.add(labelBudget); |
|
|
contentPane.add(labelBudget); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der "Ausgaben" Überschrift für die Berechnungstabelle |
|
|
JLabel labelExpenses = new JLabel("Expenses"); |
|
|
JLabel labelExpenses = new JLabel("Expenses"); |
|
|
labelExpenses.setBounds(390, 8, 56, 14); |
|
|
labelExpenses.setBounds(390, 8, 56, 14); |
|
|
contentPane.add(labelExpenses); |
|
|
contentPane.add(labelExpenses); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der "Restbudget" Überschrift für die Berechnungstabelle |
|
|
JLabel labelBalance = new JLabel("Balance"); |
|
|
JLabel labelBalance = new JLabel("Balance"); |
|
|
labelBalance.setBounds(543, 8, 46, 14); |
|
|
|
|
|
|
|
|
labelBalance.setBounds(525, 8, 46, 14); |
|
|
contentPane.add(labelBalance); |
|
|
contentPane.add(labelBalance); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der "Erspartes" Überschrift für die Berechnungstabelle |
|
|
|
|
|
JLabel labelSavings = new JLabel("Savings"); |
|
|
|
|
|
labelSavings.setBounds(660, 8, 46, 14); |
|
|
|
|
|
contentPane.add(labelSavings); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Images für "Budget" in der Tabelle |
|
|
labelBudgetImage = new JLabel(""); |
|
|
labelBudgetImage = new JLabel(""); |
|
|
labelBudgetImage.setBounds(255, 22, 46, 55); |
|
|
labelBudgetImage.setBounds(255, 22, 46, 55); |
|
|
Image image1 = new ImageIcon(this.getClass().getResource("/money.png")).getImage(); |
|
|
Image image1 = new ImageIcon(this.getClass().getResource("/money.png")).getImage(); |
|
|
labelBudgetImage.setIcon(new ImageIcon(image1)); |
|
|
labelBudgetImage.setIcon(new ImageIcon(image1)); |
|
|
contentPane.add(labelBudgetImage); |
|
|
contentPane.add(labelBudgetImage); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Images für "Ausgaben" in der Tabelle |
|
|
labelExpensesImage = new JLabel(""); |
|
|
labelExpensesImage = new JLabel(""); |
|
|
labelExpensesImage.setBounds(400, 22, 46, 55); |
|
|
labelExpensesImage.setBounds(400, 22, 46, 55); |
|
|
Image image2 = new ImageIcon(this.getClass().getResource("/wings-icon.png")).getImage(); |
|
|
Image image2 = new ImageIcon(this.getClass().getResource("/wings-icon.png")).getImage(); |
|
|
labelExpensesImage.setIcon(new ImageIcon(image2)); |
|
|
labelExpensesImage.setIcon(new ImageIcon(image2)); |
|
|
contentPane.add(labelExpensesImage); |
|
|
contentPane.add(labelExpensesImage); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Images für "Restbudget" in der Tabelle |
|
|
labelBalancetImage = new JLabel("New labelBalance"); |
|
|
labelBalancetImage = new JLabel("New labelBalance"); |
|
|
labelBalancetImage.setBounds(543, 22, 34, 55); |
|
|
labelBalancetImage.setBounds(543, 22, 34, 55); |
|
|
Image image3 = new ImageIcon(this.getClass().getResource("/Money-icon.png")).getImage(); |
|
|
Image image3 = new ImageIcon(this.getClass().getResource("/Money-icon.png")).getImage(); |
|
|
labelBalancetImage.setIcon(new ImageIcon(image3)); |
|
|
labelBalancetImage.setIcon(new ImageIcon(image3)); |
|
|
contentPane.add(labelBalancetImage); |
|
|
contentPane.add(labelBalancetImage); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Images für "Erspartes" in der Tabelle |
|
|
|
|
|
labelSavingsImage = new JLabel(""); |
|
|
|
|
|
labelSavingsImage.setBounds(660, 22, 46, 55); |
|
|
|
|
|
Image image4 = new ImageIcon(this.getClass().getResource("/savings-icon.png")).getImage(); |
|
|
|
|
|
labelSavingsImage.setIcon(new ImageIcon(image4)); |
|
|
|
|
|
contentPane.add(labelSavingsImage); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Überschrift "Ausgaben" für das Textfeld Ausgaben |
|
|
JLabel budgetAusgeben = new JLabel("Ausgaben"); |
|
|
JLabel budgetAusgeben = new JLabel("Ausgaben"); |
|
|
budgetAusgeben.setBounds(10, 185, 63, 14); |
|
|
|
|
|
|
|
|
budgetAusgeben.setBounds(10, 185, 80, 20); |
|
|
budgetAusgeben.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
budgetAusgeben.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
contentPane.add(budgetAusgeben); |
|
|
contentPane.add(budgetAusgeben); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Überschrift "Leeren" für den löschen Button |
|
|
this.leeren = new JLabel("Leeren"); |
|
|
this.leeren = new JLabel("Leeren"); |
|
|
leeren.setBounds(317, 253, 115, 14); |
|
|
leeren.setBounds(317, 253, 115, 14); |
|
|
leeren.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
leeren.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
contentPane.add(leeren); |
|
|
contentPane.add(leeren); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen und hinzufügen des "Löschen" Buttons |
|
|
this.loeschen = new JButton("L\u00F6schen"); |
|
|
this.loeschen = new JButton("L\u00F6schen"); |
|
|
loeschen.setBounds(301, 281, 89, 23); |
|
|
loeschen.setBounds(301, 281, 89, 23); |
|
|
contentPane.add(loeschen); |
|
|
contentPane.add(loeschen); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen und hinzufügen des "Exit" Buttons |
|
|
this.exit = new JButton("Exit\r\n"); |
|
|
this.exit = new JButton("Exit\r\n"); |
|
|
exit.setBounds(477, 281, 95, 23); |
|
|
exit.setBounds(477, 281, 95, 23); |
|
|
contentPane.add(exit); |
|
|
contentPane.add(exit); |
|
|
|
|
|
|
|
|
JLabel beendne = new JLabel("Beenden"); |
|
|
|
|
|
beendne.setBounds(491, 253, 81, 14); |
|
|
|
|
|
beendne.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
|
|
|
contentPane.add(beendne); |
|
|
|
|
|
|
|
|
//Einfügen der Überschrift "Beenden" über dem "exit" Button |
|
|
|
|
|
JLabel beenden = new JLabel("Beenden"); |
|
|
|
|
|
beenden.setBounds(491, 253, 81, 14); |
|
|
|
|
|
beenden.setFont(new Font("Estrangelo Edessa", Font.BOLD, 14)); |
|
|
|
|
|
contentPane.add(beenden); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Platzhalters für die Budget Summe |
|
|
budgetDispaly = new JLabel("0.0 \u20AC"); |
|
|
budgetDispaly = new JLabel("0.0 \u20AC"); |
|
|
budgetDispaly.setBounds(255, 82, 86, 14); |
|
|
budgetDispaly.setBounds(255, 82, 86, 14); |
|
|
budgetDispaly.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
budgetDispaly.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
contentPane.add(budgetDispaly); |
|
|
contentPane.add(budgetDispaly); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Platzhalters für die Asugaben Summe |
|
|
expensesDisplay = new JLabel("0.0 \u20AC"); |
|
|
expensesDisplay = new JLabel("0.0 \u20AC"); |
|
|
expensesDisplay.setBounds(390, 82, 110, 14); |
|
|
expensesDisplay.setBounds(390, 82, 110, 14); |
|
|
expensesDisplay.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
expensesDisplay.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
contentPane.add(expensesDisplay); |
|
|
contentPane.add(expensesDisplay); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Platzhalters für die Restbudget Differenz |
|
|
balanceDisplay = new JLabel("0.0 \u20AC"); |
|
|
balanceDisplay = new JLabel("0.0 \u20AC"); |
|
|
balanceDisplay.setBounds(543, 82, 85, 14); |
|
|
balanceDisplay.setBounds(543, 82, 85, 14); |
|
|
balanceDisplay.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
balanceDisplay.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
contentPane.add(balanceDisplay); |
|
|
contentPane.add(balanceDisplay); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen des Platzhalters für die Erspartes Summe |
|
|
|
|
|
savingsDisplay = new JLabel("0.0 \u20AC"); |
|
|
|
|
|
savingsDisplay.setBounds(660, 82, 85, 14); |
|
|
|
|
|
savingsDisplay.setFont(new Font("Tahoma", Font.BOLD, 12)); |
|
|
|
|
|
contentPane.add(savingsDisplay); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen und hinzufügen des "Hinzufügen" Buttons |
|
|
|
|
|
this.hinzufuegen = new JButton("Hinzuf\u00fcgen"); |
|
|
|
|
|
hinzufuegen.setBounds(660, 126, 100, 23); |
|
|
|
|
|
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 |
|
|
textExpensesName = new JTextField(); |
|
|
textExpensesName = new JTextField(); |
|
|
textExpensesName.setBounds(60, 221, 128, 20); |
|
|
textExpensesName.setBounds(60, 221, 128, 20); |
|
|
textExpensesName.setToolTipText(""); |
|
|
textExpensesName.setToolTipText(""); |
|
|
contentPane.add(textExpensesName); |
|
|
contentPane.add(textExpensesName); |
|
|
textExpensesName.setColumns(10); |
|
|
textExpensesName.setColumns(10); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Überschrifft für das Textfeld der Ausgaben Beschreibung |
|
|
ausgabenName = new JLabel(" Name"); |
|
|
ausgabenName = new JLabel(" Name"); |
|
|
ausgabenName.setBounds(10, 224, 46, 14); |
|
|
ausgabenName.setBounds(10, 224, 46, 14); |
|
|
contentPane.add(ausgabenName); |
|
|
contentPane.add(ausgabenName); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Überschrift für das Textfeld des Ausgabenbetrages |
|
|
ausgabenBetrag = new JLabel(" Betrag"); |
|
|
ausgabenBetrag = new JLabel(" Betrag"); |
|
|
ausgabenBetrag.setBounds(10, 253, 46, 14); |
|
|
ausgabenBetrag.setBounds(10, 253, 46, 14); |
|
|
contentPane.add(ausgabenBetrag); |
|
|
contentPane.add(ausgabenBetrag); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Überschrift für das Textfeld des Budgetbetrages |
|
|
budgetBetrag = new JLabel(" Betrag"); |
|
|
budgetBetrag = new JLabel(" Betrag"); |
|
|
budgetBetrag.setBounds(10, 100, 46, 14); |
|
|
budgetBetrag.setBounds(10, 100, 46, 14); |
|
|
contentPane.add(budgetBetrag); |
|
|
contentPane.add(budgetBetrag); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen einer Scrollleiste |
|
|
JScrollPane scrollPane_1 = new JScrollPane(); |
|
|
JScrollPane scrollPane_1 = new JScrollPane(); |
|
|
scrollPane_1.setBounds(347, 126, 136, 88); |
|
|
scrollPane_1.setBounds(347, 126, 136, 88); |
|
|
contentPane.add(scrollPane_1); |
|
|
contentPane.add(scrollPane_1); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Tabelle für die Ausgaben |
|
|
myTable = new JTable(); |
|
|
myTable = new JTable(); |
|
|
myTable.setColumnSelectionAllowed(true); |
|
|
myTable.setColumnSelectionAllowed(true); |
|
|
myTable.setCellSelectionEnabled(true); |
|
|
myTable.setCellSelectionEnabled(true); |
|
@ -209,6 +272,7 @@ public class MeinGui extends JFrame implements ActionListener, KeyListener { |
|
|
}); |
|
|
}); |
|
|
scrollPane_1.setViewportView(myTable); |
|
|
scrollPane_1.setViewportView(myTable); |
|
|
|
|
|
|
|
|
|
|
|
//Einfügen der Actionlistener für die verschiedenen Buttons und Textfelder |
|
|
text1.addActionListener(this); |
|
|
text1.addActionListener(this); |
|
|
text1.addKeyListener(this); |
|
|
text1.addKeyListener(this); |
|
|
text2.addActionListener(this); |
|
|
text2.addActionListener(this); |
|
@ -220,7 +284,12 @@ public class MeinGui extends JFrame implements ActionListener, KeyListener { |
|
|
loeschen.addActionListener(this); |
|
|
loeschen.addActionListener(this); |
|
|
loeschen.addKeyListener(this); |
|
|
loeschen.addKeyListener(this); |
|
|
exit.addActionListener(this); |
|
|
exit.addActionListener(this); |
|
|
|
|
|
<<<<<<< HEAD |
|
|
exit.addKeyListener(this); |
|
|
exit.addKeyListener(this); |
|
|
|
|
|
======= |
|
|
|
|
|
hinzufuegen.addActionListener(this); |
|
|
|
|
|
erspartesLoeschen.addActionListener(this); |
|
|
|
|
|
>>>>>>> e9471140ef0f8da1cd53473243a925d48bd272c1 |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -230,16 +299,29 @@ public class MeinGui extends JFrame implements ActionListener, KeyListener { |
|
|
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(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.senden && (text1 != null && text2 != null)) { |
|
|
|
|
|
try { |
|
|
budget = Double.parseDouble(text1.getText()); |
|
|
budget = Double.parseDouble(text1.getText()); |
|
|
if (ae.getSource() == this.senden && (text1 != null && text2 != null)) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
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)) { |
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.berechne && (text1 != null && text2 != null)) { |
|
|
|
|
|
try { |
|
|
DefaultTableModel tab = (DefaultTableModel) myTable.getModel(); |
|
|
DefaultTableModel tab = (DefaultTableModel) myTable.getModel(); |
|
|
tab.addRow(new Object[] { (textExpensesName.getText()), Double.parseDouble(text2.getText()) }); |
|
|
tab.addRow(new Object[] { (textExpensesName.getText()), Double.parseDouble(text2.getText()) }); |
|
|
|
|
|
|
|
@ -247,37 +329,79 @@ public class MeinGui extends JFrame implements ActionListener, KeyListener { |
|
|
expenses += Double.parseDouble(text2.getText()); |
|
|
expenses += Double.parseDouble(text2.getText()); |
|
|
expensesDisplay.setText(setExpensesView()); |
|
|
expensesDisplay.setText(setExpensesView()); |
|
|
balanceDisplay.setText(setBalanceView()); |
|
|
balanceDisplay.setText(setBalanceView()); |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception e) { |
|
|
|
|
|
showMessageDialog(null, "Sie müssen ihre Ausgabe eingeben!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
else if (ae.getSource() == this.hinzufuegen) { |
|
|
|
|
|
erspartesHinzufuegen(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void loescheErspartes() { |
|
|
|
|
|
erspartes = 0.0; |
|
|
|
|
|
savingsDisplay.setText("0.0 \u20AC"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void erspartesHinzufuegen() { |
|
|
|
|
|
erspartes += (budget - expenses); |
|
|
|
|
|
budget = 0.0; |
|
|
|
|
|
expenses = 0.0; |
|
|
|
|
|
balance = 0.0; |
|
|
|
|
|
text1.setText(null); |
|
|
|
|
|
text2.setText(null); |
|
|
|
|
|
budgetDispaly.setText("0.0 \u20AC"); |
|
|
|
|
|
expensesDisplay.setText("0.0 \u20AC"); |
|
|
|
|
|
balanceDisplay.setText("0.0 \u20AC"); |
|
|
|
|
|
savingsDisplay.setText(Double.toString(erspartes) + " \u20AC"); |
|
|
|
|
|
textExpensesName.setText(null); |
|
|
|
|
|
((DefaultTableModel) myTable.getModel()).setRowCount(0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static void exitButton() { |
|
|
public static void exitButton() { |
|
|
System.exit(0); |
|
|
System.exit(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void leeren() { |
|
|
public static void leeren() { |
|
|
|
|
|
<<<<<<< HEAD |
|
|
text1.setText(""); |
|
|
text1.setText(""); |
|
|
text2.setText(""); |
|
|
text2.setText(""); |
|
|
budgetDispaly.setText("0.0 €"); |
|
|
budgetDispaly.setText("0.0 €"); |
|
|
expensesDisplay.setText("0.0 €"); |
|
|
expensesDisplay.setText("0.0 €"); |
|
|
balanceDisplay.setText("0.0 €"); |
|
|
balanceDisplay.setText("0.0 €"); |
|
|
textExpensesName.setText(""); |
|
|
textExpensesName.setText(""); |
|
|
|
|
|
======= |
|
|
|
|
|
budget = 0.0; |
|
|
|
|
|
expenses = 0.0; |
|
|
|
|
|
balance = 0.0; |
|
|
|
|
|
text1.setText(null); |
|
|
|
|
|
text2.setText(null); |
|
|
|
|
|
budgetDispaly.setText("0.0 \u20AC"); |
|
|
|
|
|
expensesDisplay.setText("0.0 \u20AC"); |
|
|
|
|
|
balanceDisplay.setText("0.0 \u20AC"); |
|
|
|
|
|
textExpensesName.setText(null); |
|
|
|
|
|
>>>>>>> e9471140ef0f8da1cd53473243a925d48bd272c1 |
|
|
((DefaultTableModel) myTable.getModel()).setRowCount(0); |
|
|
((DefaultTableModel) myTable.getModel()).setRowCount(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static String setBudgetView() { |
|
|
public static String setBudgetView() { |
|
|
String result = budget + " €"; |
|
|
|
|
|
|
|
|
String result = budget + " �"; |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static String setBalanceView() { |
|
|
public static String setBalanceView() { |
|
|
String result = budget - expenses + " €"; |
|
|
|
|
|
|
|
|
String result = budget - expenses + " �"; |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static String setExpensesView() { |
|
|
public static String setExpensesView() { |
|
|
String result = "-" + expenses + " €"; |
|
|
|
|
|
|
|
|
String result = "-" + expenses + " �"; |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|