My doubt is as follows, should I pass the parameters obtained from a JTextField to the setter methods of the User class? or pass them directly to the constructor of the User class, what would be the difference?
//Esta es la clase registro pero resumida//
public class Registro extends JFrame implements ActionListener{
private JTextField campoNombre,campoApellido,campoCorreo,campoNombreUsuario;
private JPasswordField campoContrasena;
private JRadioButton masculino,femenino;
private ButtonGroup grupo;
private JButton finalizar,limpiar;
public Registro(){
super("Registro OO");
Toolkit posicionMonitor = Toolkit.getDefaultToolkit();
Dimension tamanio = posicionMonitor.getScreenSize();
int anchoVentana = tamanio.width;
int altoVentana = tamanio.height;
setBounds(((anchoVentana/2)-(400/2)),((altoVentana/2)-(500/2)),400,500);
this.setResizable(false);
iniciarComponentes();
}
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(limpiar)){
limpiaCampos();
}
else if(e.getSource().equals(finalizar)){
tomaDatos();
}
}
public void tomaDatos(){
String sex ="";
if(masculino.isSelected())
sex = "Masculino";
else
sex = "Femenino";
Usuario nuevoUsuario = new Usuario(campoNombre.getText(),campoApellido.getText(),campoNombreUsuario.getText(),
campoCorreo.getText(),sex,campoContrasena.getPassword());
JOptionPane.showMessageDialog(null, "Registro Exitoso","Registrado",JOptionPane.DEFAULT_OPTION);
limpiaCampos();
}