Person shared = _application.getUserByName("Shared"); if (shared != null) { add(createTotalField(shared)); }  JPanel fixedAmountPanel = new JPanel(); JLabel fixedAmountLabel = new JLabel("Fixed amount"); _fixedField = new JFormattedTextField( new NumberFormatter(NUMBER_FORMAT)); _fixedField.setValue(new Double(_sharedFixedAmount)); _fixedField.setFocusLostBehavior(JFormattedTextField.COMMIT); _fixedField.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { updateSharedCost(); } }); _fixedField.addFocusListener(new FocusAdapter() { public void focusLost(final FocusEvent e) { updateSharedCost(); } }); _fixedField.setPreferredSize(new Dimension(50, 18)); fixedAmountPanel.add(fixedAmountLabel); fixedAmountPanel.add(_fixedField); add(fixedAmountPanel);
  private void refreshGui() {    removeAll();    _totalFieldsForUser.clear();    Person[] users = _application.getPersonsModel().getUsers();    for (int i = 0; i < users.length; i++) {      Person user = users[i];      JPanel userSummaryArea = new JPanel();      JLabel label = new JLabel(user.getName());      JFormattedTextField totalField = new JFormattedTextField(          new NumberFormatter(NUMBER_FORMAT));      totalField.setEditable(false);      totalField.setValue(new Double(0));      totalField.setPreferredSize(new Dimension(65, 18));      _totalFieldsForUser.put(user, totalField);      userSummaryArea.add(label);      userSummaryArea.add(totalField);      add(userSummaryArea);    }        // Both these calls seem necessary to get the UI to update.    validate();    repaint();  }