3
The idea of the system is to save some information in a txt file that will be consulted by a code in Lisp, a decision tree routine will be performed and return the result to be displayed in the Java interface.
I have an object that will be filled in different screens of the system, my question is when to pass this object through the Cenes. I have the following structure:
The idea is to click a button in the view Clima
and before opening the next view, instantiate Perfil
and then call the next view.
Profile:
public class Perfil {
int clima;
int paisagem;
The method I am using to call the next view, this will be called by clicking the view button Clima
.
@FXML
private void handlePaisagemCalor(ActionEvent event) throws IOException{
Perfil perfil= new Perfil();
perfil.setClima(1);
perfil.setPaisagem(0);
Parent climaParent = FXMLLoader.load(getClass().getResource("/lisp/view/PaisagemCalor.fxml"));
Scene scene = new Scene(climaParent);
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
stage.setScene(scene);
stage.show();
}
This is one of the main disadvantages of FXML, navigation between screens. This can only be solved with static variables. I suggest you open the task manager and try changing the screens to see the impact on memory consumption.
– Gustavo Fragoso
Actually it can be done using the controller class constructor, communication and information exchange between two Scenes can be done this way. Don’t necessarily have to use Static variables
– Julio Cesar
The class
FXMLLoader
has the method.setController(ControllerClasse)
, use it to pass the Scene Controller.– Julio Cesar