I created a LoginFieldsController custom controller that inherits from the VBox class. Later in the programs I use this controller as an ordinary node like Button, TextFiled, etc. Please note that I only write pure Java code, I do not use FXML.
Question: is it better to declare LoginFieldsController nodes as the fields of the LoginFieldsController class, or inside the LoginFieldsController constructor? Outside the constructor I was doing nothing.
In other words, it would be better like this:
public class LoginFieldsController extends VBox {
private TextField loginField;
private TextField passwordField;
public LoginFieldsController( ... ) {
loginField = new TextFeild("Login");
passwordField = new TextFeild("Password");
this.addAll(loginField, passwordField);
...
}
Or that:
public class LoginFieldsController extends VBox {
//no fields in that class
public LoginFieldsController( ... ) {
TextField loginField = new TextFeild("Login");
TextField passwordField = new TextFeild("Password");
this.addAll(loginField, passwordField);
...
}