|
@ -23,6 +23,11 @@ import javax.swing.JSeparator; |
|
|
import javax.swing.JScrollPane; |
|
|
import javax.swing.JScrollPane; |
|
|
import javax.swing.JTable; |
|
|
import javax.swing.JTable; |
|
|
import javax.swing.table.DefaultTableModel; |
|
|
import javax.swing.table.DefaultTableModel; |
|
|
|
|
|
import javax.swing.border.EtchedBorder; |
|
|
|
|
|
import javax.swing.border.MatteBorder; |
|
|
|
|
|
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 { |
|
|
|
|
|
|
|
@ -44,12 +49,11 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
public static int budget; |
|
|
public static int budget; |
|
|
public static int expenses; |
|
|
public static int expenses; |
|
|
public static int balance; |
|
|
public static int balance; |
|
|
private JTextField textExpensesName; |
|
|
|
|
|
private JLabel ausgabenName; |
|
|
|
|
|
private JLabel ausgabenBetrag; |
|
|
|
|
|
private JLabel budgetBetrag; |
|
|
|
|
|
private JTable myTable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static JTextField textExpensesName; |
|
|
|
|
|
public static JLabel ausgabenName; |
|
|
|
|
|
private static JLabel ausgabenBetrag; |
|
|
|
|
|
private static JLabel budgetBetrag; |
|
|
|
|
|
private static JTable myTable; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Launch the application. |
|
|
* Launch the application. |
|
@ -198,26 +202,23 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
contentPane.add(budgetBetrag); |
|
|
contentPane.add(budgetBetrag); |
|
|
|
|
|
|
|
|
JScrollPane scrollPane_1 = new JScrollPane(); |
|
|
JScrollPane scrollPane_1 = new JScrollPane(); |
|
|
scrollPane_1.setBounds(323, 126, 197, 88); |
|
|
|
|
|
|
|
|
scrollPane_1.setBounds(347, 126, 136, 88); |
|
|
contentPane.add(scrollPane_1); |
|
|
contentPane.add(scrollPane_1); |
|
|
|
|
|
|
|
|
myTable = new JTable(); |
|
|
myTable = new JTable(); |
|
|
myTable.setModel(new DefaultTableModel( |
|
|
|
|
|
new Object[][] { |
|
|
|
|
|
}, |
|
|
|
|
|
new String[] { |
|
|
|
|
|
"Name", "Kosten" |
|
|
|
|
|
} |
|
|
|
|
|
) { |
|
|
|
|
|
Class[] columnTypes = new Class[] { |
|
|
|
|
|
String.class, Integer.class |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
myTable.setColumnSelectionAllowed(true); |
|
|
|
|
|
myTable.setCellSelectionEnabled(true); |
|
|
|
|
|
myTable.setBorder(UIManager.getBorder("Tree.editorBorder")); |
|
|
|
|
|
myTable.setFont(new Font("Tahoma", Font.BOLD, 11)); |
|
|
|
|
|
myTable.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Name", "Kosten" }) { |
|
|
|
|
|
Class[] columnTypes = new Class[] { String.class, Integer.class }; |
|
|
|
|
|
|
|
|
public Class getColumnClass(int columnIndex) { |
|
|
public Class getColumnClass(int columnIndex) { |
|
|
return columnTypes[columnIndex]; |
|
|
return columnTypes[columnIndex]; |
|
|
} |
|
|
} |
|
|
boolean[] columnEditables = new boolean[] { |
|
|
|
|
|
false, true |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean[] columnEditables = new boolean[] { false, false }; |
|
|
|
|
|
|
|
|
public boolean isCellEditable(int row, int column) { |
|
|
public boolean isCellEditable(int row, int column) { |
|
|
return columnEditables[column]; |
|
|
return columnEditables[column]; |
|
|
} |
|
|
} |
|
@ -253,7 +254,10 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
expensesDisplay.setText(setExpensesView()); |
|
|
expensesDisplay.setText(setExpensesView()); |
|
|
balance = Integer.parseInt(text1.getText()) - Integer.parseInt(text2.getText()); |
|
|
balance = Integer.parseInt(text1.getText()) - Integer.parseInt(text2.getText()); |
|
|
balanceDisplay.setText(setBalanceView()); |
|
|
balanceDisplay.setText(setBalanceView()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
DefaultTableModel tab = (DefaultTableModel)myTable.getModel(); |
|
|
|
|
|
tab.addRow(new Object [] {(textExpensesName.getText()) , Integer.parseInt(text2.getText())}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -267,9 +271,10 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
budgetDispaly.setText(null); |
|
|
budgetDispaly.setText(null); |
|
|
expensesDisplay.setText(null); |
|
|
expensesDisplay.setText(null); |
|
|
balanceDisplay.setText(null); |
|
|
balanceDisplay.setText(null); |
|
|
|
|
|
textExpensesName.setText(null); |
|
|
|
|
|
((DefaultTableModel)myTable.getModel()).setRowCount(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String setBudgetView() { |
|
|
public static String setBudgetView() { |
|
|
String result = budget + " €"; |
|
|
String result = budget + " €"; |
|
|
return result; |
|
|
return result; |
|
@ -284,4 +289,5 @@ public class MeinGui extends JFrame implements ActionListener { |
|
|
String result = balance + " €"; |
|
|
String result = balance + " €"; |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |