Put the errors in another method and added a joptionpane with error msg