so basically I have a simple example with a main class that is a stage and when you press a button a new stage will appear over it. If you close it and reopen it over and over eventually the memory that program uses will go up without going back down. Is there a way to get this code to work so that the memory will go back down to the starting point before the button is clicked? Down below are the two classes I used.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class main extends Application{
public static void main(String[] args){
launch(args);
}
public void start(Stage stage) throws Exception {
GridPane grid = new GridPane();
Button button = new Button("New Screen");
button.setOnAction(new NewScreen());
grid.add(button,0,0);
Scene scene = new Scene(grid,200,200);
stage.setScene(scene);
stage.show();
}
}
and the action class:
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class NewScreen implements EventHandler<ActionEvent>{
public void handle(ActionEvent arg0){
Stage stage = new Stage();
GridPane grid = new GridPane();
Scene scene = new Scene(grid,300,300);
stage.setScene(scene);
stage.show();
}
}
Thank you.