Browse Source

Konflikt loesen

master
Adah Boukhari 5 years ago
parent
commit
829a674a2e
  1. BIN
      Budget Projekt/bin/MeinBudgetView/MeinGui$2.class
  2. 64
      Budget Projekt/src/MeinBudgetView/MeinGui.java

BIN
Budget Projekt/bin/MeinBudgetView/MeinGui$2.class

64
Budget Projekt/src/MeinBudgetView/MeinGui.java

@ -23,6 +23,11 @@ import javax.swing.JSeparator;
import javax.swing.JScrollPane;
import javax.swing.JTable;
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 {
@ -44,12 +49,11 @@ public class MeinGui extends JFrame implements ActionListener {
public static int budget;
public static int expenses;
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.
@ -178,46 +182,43 @@ public class MeinGui extends JFrame implements ActionListener {
balanceDisplay.setBounds(543, 82, 85, 14);
balanceDisplay.setFont(new Font("Tahoma", Font.BOLD, 12));
contentPane.add(balanceDisplay);
textExpensesName = new JTextField();
textExpensesName.setBounds(60, 221, 128, 20);
textExpensesName.setToolTipText("");
contentPane.add(textExpensesName);
textExpensesName.setColumns(10);
ausgabenName = new JLabel(" Name");
ausgabenName.setBounds(10, 224, 46, 14);
contentPane.add(ausgabenName);
ausgabenBetrag = new JLabel(" Betrag");
ausgabenBetrag.setBounds(10, 253, 46, 14);
contentPane.add(ausgabenBetrag);
budgetBetrag = new JLabel(" Betrag");
budgetBetrag.setBounds(10, 100, 46, 14);
contentPane.add(budgetBetrag);
JScrollPane scrollPane_1 = new JScrollPane();
scrollPane_1.setBounds(323, 126, 197, 88);
scrollPane_1.setBounds(347, 126, 136, 88);
contentPane.add(scrollPane_1);
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) {
return columnTypes[columnIndex];
}
boolean[] columnEditables = new boolean[] {
false, true
};
boolean[] columnEditables = new boolean[] { false, false };
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
@ -253,8 +254,11 @@ public class MeinGui extends JFrame implements ActionListener {
expensesDisplay.setText(setExpensesView());
balance = Integer.parseInt(text1.getText()) - Integer.parseInt(text2.getText());
balanceDisplay.setText(setBalanceView());
}
}
DefaultTableModel tab = (DefaultTableModel)myTable.getModel();
tab.addRow(new Object [] {(textExpensesName.getText()) , Integer.parseInt(text2.getText())});
}
public void exitButton() {
@ -267,9 +271,10 @@ public class MeinGui extends JFrame implements ActionListener {
budgetDispaly.setText(null);
expensesDisplay.setText(null);
balanceDisplay.setText(null);
textExpensesName.setText(null);
((DefaultTableModel)myTable.getModel()).setRowCount(0);
}
public static String setBudgetView() {
String result = budget + " €";
return result;
@ -283,5 +288,6 @@ public class MeinGui extends JFrame implements ActionListener {
public static String setBalanceView() {
String result = balance + " €";
return result;
}
}
}
Loading…
Cancel
Save