+
+ // 2) "address" panel
+ initAddressPanel();
+
+ // x)Only for developing:
+ /* DEBUG: */ this.addContact.setVisible(true);
+ }
+
+ /**
+ * Initializes address panel
+ */
+ private void initAddressPanel () {
+ // Panel "address" input boxes
+ JPanel addressPanel = new JPanel();
+ addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.Y_AXIS));
+
+ // Set border to titled version
+ addressPanel.setBorder(new TitledBorder(this.generateBorderTitle("address")));
+
+ // Init all elements:
+ // 1) Street and number together
+ JPanel streetNumberPanel = new JPanel();
+ streetNumberPanel.setLayout(new GridLayout(1, 4));
+
+ // Label for street
+ JLabel streetLabel = new JLabel(this.getBundle().getString("AddressbookFrame.street.text"));
+
+ // Init text field with label
+ JTextField street = new JTextField(20);
+ street.setToolTipText(this.getBundle().getString("AddressbookFrame.street.tooltipText"));
+
+ // Add both to street panel
+ streetNumberPanel.add(streetLabel);
+ streetNumberPanel.add(street);
+
+ // Number label
+ JLabel numberLabel = new JLabel(this.getBundle().getString("AddressbookFrame.number.text"));
+
+ // And text field, but only accept numbers
+ JTextField number = new JTextField(4);
+ number.setToolTipText(this.getBundle().getString("AddressbookFrame.number.tooltipText"));
+
+ // Add number verifier
+ number.setInputVerifier(new InputVerifier() {
+
+ /**
+ * Method to verify that the entered data is a number.
+ *
+ * @param input Input to verify
+ * @return Whether the data is a number
+ */
+ @Override
+ public boolean verify (final JComponent input) {
+ // Cast on text field
+ JTextField text = (JTextField) input;
+
+ // Default is passed
+ boolean isValid = true;
+
+ // Try to convert input text to a number
+ try {
+ int num = Integer.valueOf(text.getText());
+ } catch (final NumberFormatException ex) {
+ // Didn't work
+ isValid = false;
+ }
+
+ // Return status
+ return isValid;
+ }
+ });
+
+ // Add both to street panel
+ streetNumberPanel.add(numberLabel);
+ streetNumberPanel.add(number);
+
+ // Add panel to address panel
+ addressPanel.add(streetNumberPanel);
+
+ // 2) ZIP code and ccity name
+ JPanel zipCityPanel = new JPanel();
+ zipCityPanel.setLayout(new GridLayout(1, 4));
+
+ // Label for ZIP code, again numbers only
+ JLabel zipLabel = new JLabel(this.getBundle().getString("AddressbookFrame.zip.text"));
+
+ // Init text field with label
+ JTextField zip = new JTextField(20);
+ zip.setToolTipText(this.getBundle().getString("AddressbookFrame.zip.tooltipText"));
+
+ // Add number verifier
+ zip.setInputVerifier(new InputVerifier() {
+
+ /**
+ * Method to verify that the entered data is a number.
+ *
+ * @param input Input to verify
+ * @return Whether the data is a number
+ */
+ @Override
+ public boolean verify (final JComponent input) {
+ // Cast on text field
+ JTextField text = (JTextField) input;
+
+ // Default is passed
+ boolean isValid = true;
+
+ // Try to convert input text to a number
+ try {
+ int num = Integer.valueOf(text.getText());
+ } catch (final NumberFormatException ex) {
+ // Didn't work
+ isValid = false;
+ }
+
+ // Return status
+ return isValid;
+ }
+ });
+
+ // Add both to street panel
+ zipCityPanel.add(zipLabel);
+ zipCityPanel.add(zip);
+
+ // Label for street
+ JLabel cityLabel = new JLabel(this.getBundle().getString("AddressbookFrame.city.text"));
+
+ // Init text field with label
+ JTextField city = new JTextField(20);
+ city.setToolTipText(this.getBundle().getString("AddressbookFrame.city.tooltipText"));
+
+ // Add both to street panel
+ zipCityPanel.add(cityLabel);
+ zipCityPanel.add(city);
+
+ // Add panel to address panel
+ addressPanel.add(zipCityPanel);
+
+ // Add panel to dialog
+ this.addContact.add(addressPanel);