public void propertyChange(PropertyChangeEvent e) {
		String prop = e.getPropertyName();

		if (isVisible()
				&& (e.getSource() == optionPane)
				&& (JOptionPane.VALUE_PROPERTY.equals(prop) || JOptionPane.INPUT_VALUE_PROPERTY
						.equals(prop))) {
			Object value = optionPane.getValue();

			if (value == JOptionPane.UNINITIALIZED_VALUE) {
				// ignore reset
				return;
			}

			// Reset the JOptionPane's value.
			// If you don't do this, then if the user
			// presses the same button next time, no
			// property change event will be fired.
			optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

			if (btnString1.equals(value)) { // Enter pressed
				int width = -1;
				int height = -1;
				try {
					width = Integer.parseInt(textFieldWidth.getText());
				} catch (NumberFormatException exc) {
					// width text was invalid
					textFieldWidth.selectAll();
					JOptionPane.showMessageDialog(NewMapDialog.this,
							"The value \"" + textFieldWidth.getText()
									+ "\" is not an integer.",
							"Please enter an integer value.",
							JOptionPane.ERROR_MESSAGE);
					textFieldWidth.requestFocusInWindow();
					return;
				}
				try {
					height = Integer.parseInt(textFieldHeight.getText());
				} catch (NumberFormatException exc) {
					// height text was invalid
					textFieldHeight.selectAll();
					JOptionPane.showMessageDialog(NewMapDialog.this,
							"The value \"" + textFieldHeight.getText()
									+ "\" is not an integer.",
							"Please enter an integer value.",
							JOptionPane.ERROR_MESSAGE);
					textFieldHeight.requestFocusInWindow();
					return;
				}

				// Success:
				worldIO.renewWorld(width, height);
				clearAndHide();

			} else if (btnString2.equals(value)) { // Cancel pressed
				clearAndHide();
			}
		}

	}