public JPanel initTextFields() { textfeld = new JTextField[columnNames.length - 1]; JPanel panel = new JPanel(new GridLayout(columnNames.length, 2)); for (int i = 0; i < textfeld.length; i++) { textfeld[i] = new JTextField(15); textfeld[i].setName(columnNames[i]); JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JLabel l = new JLabel(columnNames[i]); p.add(l); panel.add(p); p = new JPanel(new FlowLayout(FlowLayout.LEFT)); p.add(textfeld[i]); panel.add(p); } kategorie = new JComboBox<Kategorie>(); kategorie.setName(columnNames[columnNames.length - 1]); kategorie.setRenderer(new MyListCellRenderer()); JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JLabel l = new JLabel(columnNames[columnNames.length - 1]); p.add(l); panel.add(p); p = new JPanel(new FlowLayout(FlowLayout.LEFT)); p.add(kategorie); panel.add(p); DataBinder d = new DataBinder(); try { d.bindTo_String( kategorie, new EntityComboBoxModel<Kategorie>(BL.getKategorieListe()), b == null ? null : b.getKKbz()); } catch (DALException e) { JOptionPane.showMessageDialog(this, e.getMessage()); } if (b != null) { d.bindTo_Date(textfeld[0], b.getDatum()); d.bindTo_String(textfeld[1], b.getKommentar()); d.bindTo_double(textfeld[2], b.getSteuersatz()); d.bindTo_double(textfeld[3], b.getBetrag()); } else { d.bindTo_Date(textfeld[0], new Date()); } return panel; }
public EditBuchungszeileDialog(JFrame owner, Buchungszeile b) { super(owner, "Buchungszeile " + b.getBuchungszeileID() + " bearbeiten", true); this.b = b; initDialog(); }