Ejemplo n.º 1
0
  public JPanel initTextFields() {
    textfeld = new JTextField[columnNames.length];

    JPanel panel = new JPanel(new GridLayout(textfeld.length, 1));

    for (int i = 0; i < textfeld.length; i++) {
      textfeld[i] = new JTextField(20);
      textfeld[i].addKeyListener(this);
      textfeld[i].setName(columnNames[i]);
      JLabel l = new JLabel(columnNames[i]);

      JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      p.add(l);
      p.add(textfeld[i]);

      panel.add(p);
    }
    if (k != null) {
      DataBinder d = new DataBinder();
      d.bindTo_String(textfeld[0], k.getFirma());
      d.bindTo_String(textfeld[1], k.getName());
      d.bindTo_String(textfeld[2], k.getTelefon());
    }

    return panel;
  }
Ejemplo n.º 2
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == save) {

      try {
        DataBinder b = new DataBinder();
        String firma = b.bindFrom_String(textfeld[0], new StandardRule());
        String name = b.bindFrom_String(textfeld[1], new StandardRule());
        String telefon = b.bindFrom_String(textfeld[2], new StandardRule());

        if (!b.hasErrors()) {
          if (k != null) {
            k.setFirma(firma);
            k.setName(name);
            k.setTelefon(telefon);
            BL.updateKontakt(k);
            // JOptionPane.showMessageDialog(this,
            // "Eintrag wurde erfolgreich bearbeitet");
          } else {
            k = new Kontakt(firma, name, telefon);
            BL.saveKontakt(k);
            // JOptionPane.showMessageDialog(this,
            // "Eintrag wurde erfolgreich hinzugefügt");
          }
          dispose();
        } else {
          JOptionPane.showMessageDialog(this, b.getErrors());
        }
      } catch (IllegalArgumentException iae) {
        JOptionPane.showMessageDialog(this, iae.getMessage());
      } catch (InvalidObjectException ioe) {
        JOptionPane.showMessageDialog(this, ioe.getMessage());
      } catch (DALException de) {
        de.printStackTrace();
        JOptionPane.showMessageDialog(this, de.getMessage());
        System.out.println(de.getMessage());
      }
    } else if (e.getSource() == cancel) {
      dispose();
    }
  }
Ejemplo n.º 3
0
 public EditKontaktDialog(JFrame owner, Kontakt k) {
   super(owner, "Kontakt " + k.getKontaktID() + " bearbeiten", true);
   this.k = k;
   initDialog();
 }