package eu.tankernn.accounts.frame;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

public class NewAccountDialog {

	JLabel lFirstName = new JLabel("First name:"), lLastName = new JLabel("Last name:");
	JTextField firstName = new JTextField(20), lastName = new JTextField(20);
	
	final JComponent[] components = {
			lFirstName, firstName, lLastName, lastName,
	};
	
	int result;

	/**
	 * Create the dialog.
	 */
	public NewAccountDialog() {
		result = JOptionPane.showConfirmDialog(null, components, "New Account", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE);
	}

	public String getFirstName() {
		return firstName.getText();
	}

	public String getLastName() {
		return lastName.getText();
	}

	public int getResult() {
		return result;
	}

	public boolean validate() {
		if (result != JOptionPane.OK_OPTION)
			return false;
		
		if (firstName.getText().isEmpty() || lastName.getText().isEmpty()) {
			JOptionPane.showMessageDialog(null, "Please fill in all the fields.");
			return false;
		}
		
		return true;
	}

}
@@ -698,32 +698,39 @@
 stName.getText()
+.trim()
 ;%0A%09%7D%0A%0A%09public St
@@ -777,16 +777,23 @@
 etText()
+.trim()
 ;%0A%09%7D%0A%0A%09p

Trim names in NewAccountDialog