Exemplo n.º 1
0
    @Override
    public void valueChanged(ListSelectionEvent e) {
      if (burgerList.getSelectedIndex() == -1) {
        gebruikerTxt.setText("");
        naamTxt.setText("");
        familienaamTxt.setText("");
        emailTxt.setText("");
      } else {
        gebruikerTxt.setEditable(false);
        naamTxt.setEditable(false);
        familienaamTxt.setEditable(false);
        emailTxt.setEditable(false);

        for (Burger b : m.getBurgers()) {
          if (burgerList.getSelectedValue().equals(b.getNaam())) {
            m.setBurger(burgerList.getSelectedValue().toString());

            gebruikerTxt.setText(b.getGebruikersnaam());
            naamTxt.setText(b.getVoornaam());
            familienaamTxt.setText(b.getFamilienaam());
            emailTxt.setText(b.getEmail());
          }
        }
      }
    }
Exemplo n.º 2
0
  public BurgerPanel(Model model, Databank data) {
    this.m = model;
    this.d = data;

    allesPanel = new JPanel(); // bevat de 2 panels

    burgerPanel = new JPanel();
    burgerPanel.setLayout(new GridBagLayout());

    gebruikersnaam = new JLabel("Gebruikersnaam");
    voornaam = new JLabel("Voornaam");
    familienaam = new JLabel("Familienaam");
    email = new JLabel("E-mail");

    gebruikerTxt = new JTextField();
    gebruikerTxt.setColumns(17);
    gebruikerTxt.setEditable(false);
    naamTxt = new JTextField();
    naamTxt.setColumns(17);
    naamTxt.setEditable(false);
    familienaamTxt = new JTextField();
    familienaamTxt.setColumns(17);
    familienaamTxt.setEditable(false);
    emailTxt = new JTextField();
    emailTxt.setColumns(17);
    emailTxt.setEditable(false);

    burgerModel = new DefaultListModel();

    for (Burger b : m.getBurgers()) {
      burgerModel.addElement(b.getNaam());
    }

    burgerList = new JList(burgerModel);
    burgerList.setLayoutOrientation(JList.VERTICAL);
    burgerList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane adminScroll = new JScrollPane(burgerList);
    adminScroll.setPreferredSize(new Dimension(150, 100));
    adminScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    burgerList.addListSelectionListener(new ListListener());
    burgerList.setSelectedIndex(0);

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridx = 1;
    c.gridy = 1;
    burgerPanel.add(gebruikersnaam, c);

    c.gridx = 2;
    c.gridy = 1;
    burgerPanel.add(gebruikerTxt, c);

    c.gridx = 1;
    c.gridy = 2;
    burgerPanel.add(voornaam, c);

    c.gridx = 2;
    c.gridy = 2;
    burgerPanel.add(naamTxt, c);

    c.gridx = 1;
    c.gridy = 3;
    burgerPanel.add(familienaam, c);

    c.gridx = 2;
    c.gridy = 3;
    burgerPanel.add(familienaamTxt, c);

    c.gridx = 1;
    c.gridy = 4;
    burgerPanel.add(email, c);

    c.gridx = 2;
    c.gridy = 4;
    burgerPanel.add(emailTxt, c);

    allesPanel.add(adminScroll, BorderLayout.LINE_START);
    allesPanel.add(burgerPanel, BorderLayout.CENTER);
  }