public class ContactView extends JPanel { /** * */ private static final long serialVersionUID = 1L; private Contact refContact; private JLabel name; private JLabel tel; // todo more stuff public ContactView(Contact contact) { if (contact != null) { this.refContact = contact; this.setLayout(new GridLayout(3,1)); this.name = new JLabel(contact.getName() + ", " + contact.getVorname()); this.name.setBackground(Color.darkGray); this.name.setFocusable(true); this.tel = new JLabel(contact.getTel()); this.tel.setFocusable(true); this.add(this.name); this.add(this.tel); } } public void addActionListener(ActionListener acl) { this.addActionListener(acl); } public void update(){ this.name.setText(this.refContact.getName()); this.tel.setText(this.refContact.getTel()); } }