I use next code, where using buttons i change current scene.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFX_ScenesChanging extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage stage) throws Exception {
Button b1 = new Button("Button 1");
VBox vb = new VBox();
vb.getChildren().add(b1);
final Scene scene1 = new Scene(vb, 200, 200);
Button b2 = new Button("Button 2");
VBox vb2 = new VBox();
vb2.getChildren().add(b2);
final Scene scene2 = new Scene(vb2, 200, 200);
b1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
stage.setScene(scene2);
}
});
b2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
stage.setScene(scene1);
}
});
stage.setScene(scene1);
stage.show();
}
}
When I press button, "old" scene stays on stage with pressed state of button and it [scene] is already inactive. To see "new" scene i need to drag and drop window.
Excuse me, if such bug already exists, in part, where scene setting is asynchroniuos. May be related toRT-19320.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFX_ScenesChanging extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(final Stage stage) throws Exception {
Button b1 = new Button("Button 1");
VBox vb = new VBox();
vb.getChildren().add(b1);
final Scene scene1 = new Scene(vb, 200, 200);
Button b2 = new Button("Button 2");
VBox vb2 = new VBox();
vb2.getChildren().add(b2);
final Scene scene2 = new Scene(vb2, 200, 200);
b1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
stage.setScene(scene2);
}
});
b2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
stage.setScene(scene1);
}
});
stage.setScene(scene1);
stage.show();
}
}
When I press button, "old" scene stays on stage with pressed state of button and it [scene] is already inactive. To see "new" scene i need to drag and drop window.
Excuse me, if such bug already exists, in part, where scene setting is asynchroniuos. May be related to