2

私はJavaFXが初めてです。メイン シーンとセカンダリ シーンがあります。最初のシーンから 2 番目のシーンに切り替えると、ウィンドウのバーが表示されます。どうすれば修正できますか?

これが私のコードです

public class ProyectoTeoriaBD1 extends Application {

Stage primaryStage;

public static void main(String[] args) {
    launch(args);
}

@Override
public void start(final Stage primaryStage) {

    this.primaryStage = primaryStage;
    GridPane gp = new GridPane();
    gp.setHgap(10);
    gp.setVgap(10);
    gp.setPadding(new Insets(25,25,25,25));

    Scene firstScene = new Scene(gp);
    Button b = new Button("Change Scene");        
    gp.add(b,1,1);
    primaryStage.setScene(firstScene);
     primaryStage.setFullScreen(true);
    primaryStage.show();



   b.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
           GridPane gp = new GridPane();
           Scene secondScene = new Scene(gp);
           Text txtSecond = new Text("Second Scene");
           gp.add(txtSecond, 1, 1);
           primaryStage.setScene(secondScene);
           primaryStage.setFullScreen(false);
           primaryStage.setFullScreen(true);

        }
    });


}

}

4

2 に答える 2

2

完全に実行可能でテスト可能なコードが役立つ場合があります。また、システム環境の詳細も提供してください。JavaFX バージョン 2.2.0 を搭載した Windows 7 64 ビットで動作する以下のコードをテストしました (自分で試してみてください)。
(詳細を提供し、最後にstackoverflowへようこそ!)

更新:わかりました、最初はプライマリ ステージがフル スクリーン モードだったと思います。その場合、フルスクリーンモードを切り替える必要があります。下記参照。

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.StackPane;
import javafx.scene.layout.VBoxBuilder;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Test extends Application {
    private Stage primaryStage;

    @Override
    public void start(Stage primaryStage) {
        this.primaryStage = primaryStage;
        this.primaryStage.setFullScreen(true);
        Button btn = new Button("Login");
        btn.setOnAction(loginClienteHandler());

        StackPane root = new StackPane();
        root.getChildren().add(btn);

        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("JavaFX version: " + com.sun.javafx.runtime.VersionInfo.getRuntimeVersion());
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public EventHandler loginClienteHandler() {
        EventHandler evh = new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                primaryStage.setScene(new Scene(VBoxBuilder.create().children(new Text("text")).build()));
                primaryStage.sizeToScene();
                primaryStage.setFullScreen(false);
                primaryStage.setFullScreen(true);
            }
        };
        return evh;
    }

    public static void main(String[] args) {
        launch(args);
    }
}
于 2013-02-06T08:50:51.780 に答える