Java Code Examples for javafx.stage.Stage#setFullScreen()

The following examples show how to use javafx.stage.Stage#setFullScreen() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarsViewer.java    From mars-sim with GNU General Public License v3.0 7 votes vote down vote up
@Override
public void start(Stage stage) {
	Group group = buildScene();

    Scene scene = new Scene(
      new StackPane(group),
      VIEWPORT_SIZE, VIEWPORT_SIZE,
      true,
      SceneAntialiasing.BALANCED
    );

    scene.setFill(Color.rgb(10, 10, 40));

    scene.setCamera(new PerspectiveCamera());

    stage.setScene(scene);
    stage.show();

    stage.setFullScreen(true);

    rotateAroundYAxis(group).play();
}
 
Example 2
Source File: Main.java    From stagedisplayviewer with MIT License 6 votes vote down vote up
@Override
public void start(final Stage primaryStage) throws IOException {
    log.info("Starting program");
    final FxUtils fxUtils = new FxUtils();

    Property.loadProperties();

    Text lowerKey = fxUtils.createLowerKey();
    midiModule = new MidiModule();
    lowerKeyHandler = new LowerKeyHandler(lowerKey, midiModule);
    thread = new Thread(lowerKeyHandler);

    primaryStage.setTitle(PROGRAM_TITLE);
    Scene scene = fxUtils.createScene(lowerKey);
    scene.setOnKeyTyped(new SceneKeyTypedHandler(primaryStage));
    primaryStage.setScene(scene);
    fxUtils.startOnCorrectScreen(primaryStage);
    primaryStage.setOnCloseRequest(getEventHandler());
    primaryStage.setFullScreen(Property.START_IN_FULLSCREEN.isTrue());
    primaryStage.show();
    thread.start();
}
 
Example 3
Source File: EarthViewer.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage stage) {
  Group group = buildScene();

  Scene scene = new Scene(
    new StackPane(group),
    VIEWPORT_SIZE, VIEWPORT_SIZE,
    true,
    SceneAntialiasing.BALANCED
  );

  scene.setFill(Color.rgb(10, 10, 40));

  scene.setCamera(new PerspectiveCamera());

  stage.setScene(scene);
  stage.show();

  stage.setFullScreen(true);

  rotateAroundYAxis(group).play();
}
 
Example 4
Source File: TripleA.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private void setupStage(
    final Stage stage, final Scene scene, final RootActionPane rootActionPane) {
  stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
  // Should be a configurable setting in the future, but for developing it's
  // better to work in non-fullscreen mode
  stage.setFullScreen(false);

  Font.loadFont(TripleA.class.getResourceAsStream(FONT_PATH), 14);
  stage.setScene(scene);
  stage.getIcons().add(new Image(getClass().getResourceAsStream(ICON_LOCATION)));
  stage.setTitle("TripleA");
  stage.show();
  stage.setOnCloseRequest(
      e -> {
        e.consume();
        rootActionPane.promptExit();
      });
}
 
Example 5
Source File: Game2048.java    From fx2048 with GNU General Public License v3.0 5 votes vote down vote up
private void setEnhancedDeviceSettings(Stage primaryStage, Scene scene) {
    var isARM = System.getProperty("os.arch").toUpperCase().contains("ARM");
    if (isARM) {
        primaryStage.setFullScreen(true);
        primaryStage.setFullScreenExitHint("");
    }

    if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
        scene.setCursor(Cursor.NONE);
    }
}
 
Example 6
Source File: ViewUtils.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
/**
 * 全屏显示
 *
 * @param stage
 */
public static void fullScreen(Stage stage){
    if (stage.isFullScreen()) {
        stage.setFullScreen(false);
    }else{
        stage.setFullScreen(true);
    }
}
 
Example 7
Source File: OctahedronTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    shapeGroup.getChildren().clear();
    generateShapes();
    root.getChildren().add(shapeGroup);
            
    camera = new AdvancedCamera();
    controller = new FPSController();
    
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    
    controller.setScene(scene);
    scene.setOnKeyPressed(event -> {
        //What key did the user press?
        KeyCode keycode = event.getCode();
        if(keycode == KeyCode.SPACE) {
            shapeGroup.getChildren().clear();
            generateShapes();                
        }
    });
    
    stage.setTitle("Random Octahedrons!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}
 
Example 8
Source File: TrapezoidTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    shapeGroup.getChildren().clear();
    generateShapes();
    root.getChildren().add(shapeGroup);
            
    camera = new AdvancedCamera();
    controller = new FPSController();
    
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    
    controller.setScene(scene);
    scene.setOnKeyPressed(event -> {
        //What key did the user press?
        KeyCode keycode = event.getCode();
        if(keycode == KeyCode.SPACE) {
            shapeGroup.getChildren().clear();
            generateShapes();                
        }
    });
    
    stage.setTitle("Random Trapezoids!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}
 
Example 9
Source File: PlatformUtils.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Same as setFullScreenWindow but modified to take a javafx Stage Also sets
 * up always on top
 */
public static boolean setFullScreenAlwaysOnTop(Stage stage, boolean fullScreen) {
    if (!Utils.isLinux()) {
        return false;
    }

    stage.setFullScreenExitHint("");
    stage.setFullScreenExitKeyCombination(null);
    stage.setFullScreen(fullScreen);
    stage.setAlwaysOnTop(fullScreen);

    return setFullScreenWindow(getWindowID(stage), fullScreen);
}
 
Example 10
Source File: Main.java    From TweetwallFX with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    BorderPane borderPane = new BorderPane();
    Scene scene = new Scene(borderPane, 1920, 1280);
    borderPane.getStyleClass().add("splash");

    final TweetwallSettings tweetwallSettings
            = Configuration.getInstance().getConfigTyped(TweetwallSettings.CONFIG_KEY, TweetwallSettings.class);

    Optional.ofNullable(tweetwallSettings.getStylesheetResource())
            .map(ClassLoader.getSystemClassLoader()::getResource)
            .map(java.net.URL::toExternalForm)
            .ifPresent(scene.getStylesheets()::add);
    Optional.ofNullable(tweetwallSettings.getStylesheetFile())
            .ifPresent(scene.getStylesheets()::add);

    StringPropertyAppender spa = new StringPropertyAppender();

    LoggerContext context = LoggerContext.getContext(false);
    org.apache.logging.log4j.core.config.Configuration config = context.getConfiguration();
    spa.start();
    LoggerConfig slc = config.getLoggerConfig(LOGGER.getName());
    slc.setLevel(Level.TRACE);
    slc.addAppender(spa, Level.TRACE, null);

    HBox statusLineHost = new HBox();
    Text statusLineText = new Text();
    statusLineText.getStyleClass().addAll("statusline");
    statusLineText.textProperty().bind(spa.stringProperty());
    statusLineHost.getChildren().add(statusLineText);

    final TagTweets tweetsTask = new TagTweets(borderPane);
    Platform.runLater(tweetsTask::start);

    scene.setOnKeyTyped((KeyEvent event) -> {
        if (event.isMetaDown() && event.getCharacter().equals("d")) {
            if (null == statusLineHost.getParent()) {
                borderPane.setBottom(statusLineHost);
            } else {
                borderPane.getChildren().remove(statusLineHost);
            }
        }
    });

    primaryStage.setTitle(tweetwallSettings.getTitle());
    primaryStage.setScene(scene);

    primaryStage.show();
    primaryStage.setFullScreen(!Boolean.getBoolean("org.tweetwallfx.disable-full-screen"));
}
 
Example 11
Source File: ConeTest.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    
    Group coneGroup = new Group();        
    for (int i = 0; i < 100; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat()*100) + 25);
        float randomHeight = (float) ((r.nextFloat()*300)+ 75);
        int randomDivisions = (int) ((r.nextFloat()*50) + 5);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Cone cone = new Cone(randomDivisions, randomRadius, randomHeight, randomColor);               
        cone.setEmissiveLightingColor(randomColor);
        cone.setEmissiveLightingOn(r.nextBoolean());
        cone.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        
        double translationX = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        cone.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        coneGroup.getChildren().add(cone);
    }
    root.getChildren().add(coneGroup);
    
    camera = new AdvancedCamera();
    controller = new FPSController();
    
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    
    controller.setScene(scene);
            
    stage.setTitle("Random Cones!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}
 
Example 12
Source File: CapsuleTest.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    
    Group capsuleGroup = new Group();        
    for (int i = 0; i < 50; i++) {
        Random r = new Random();
        //A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat() * 100) + 25);
        float randomHeight = (float) ((r.nextFloat() * 300) + 75);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        
        Capsule cap = new Capsule(randomRadius, randomHeight, randomColor);               
        cap.setEmissiveLightingColor(randomColor);
        cap.setEmissiveLightingOn(r.nextBoolean());
        cap.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        cap.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        
        capsuleGroup.getChildren().add(cap);
    }
    
    root.getChildren().add(capsuleGroup);
            
    camera = new AdvancedCamera();
    controller = new FPSController();
    
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    
    controller.setScene(scene);
            
    stage.setTitle("Hello World!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(true);
    stage.setFullScreenExitHint("");
}
 
Example 13
Source File: Game2048.java    From Game2048FX with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void postInit(Scene scene) {

    String display = Services.get(DisplayService.class)
            .map(service -> service.isTablet() ? "tablet" : "phone")
            .orElse("phone");
    scene.getStylesheets().add(GameManager.class.getResource(display + ".css").toExternalForm());

    GameModel gameModel = Injector.instantiateModelOrService(GameModel.class);
    scene.getRoot().getStyleClass().add(gameModel.getGameMode().toString().toLowerCase());
    gameModel.gameModeProperty().addListener((obs, m, m1) -> {
        scene.getRoot().getStyleClass().remove(m.toString().toLowerCase());
        scene.getRoot().getStyleClass().add(m1.toString().toLowerCase());
    });
    Stage stage = (Stage) scene.getWindow();

    if (Platform.isDesktop()) {
        Services.get(DisplayService.class)
                .ifPresent(service -> {
                    if (service.isTablet()) {
                        // tablet
                        scene.getWindow().setWidth(600);
                        scene.getWindow().setHeight(800);
                    }
                });

        stage.setTitle("2048FX");
        stage.getIcons()
                .add(new Image(GameManager.class.getResourceAsStream("Icon-60.png")));
    }

    AppViewManager.GAME_VIEW.getPresenter().ifPresent(presenter -> {
        gamePresenter = (GamePresenter) presenter;
        gamePresenter.pauseProperty().bind(pause);
        gamePresenter.stopProperty().bind(stop);
    });

    if (Platform.isDesktop() && isARMDevice()) {
        stage.setFullScreen(true);
        stage.setFullScreenExitHint("");
    }

    if (javafx.application.Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
        scene.setCursor(Cursor.NONE);
    }
}
 
Example 14
Source File: DesktopApp.java    From FXTutorials with MIT License 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    stage.setScene(new Scene(createContent()));
    stage.setFullScreen(true);
    stage.show();
}
 
Example 15
Source File: MainController.java    From Library-Assistant with Apache License 2.0 4 votes vote down vote up
@FXML
private void handleMenuFullScreen(ActionEvent event) {
    Stage stage = getStage();
    stage.setFullScreen(!stage.isFullScreen());
}
 
Example 16
Source File: LaunchScreeenController.java    From FakeImageDetection with GNU General Public License v3.0 4 votes vote down vote up
@FXML
private void loadFullScreen(ActionEvent event) {
    Stage stage = (Stage) rootPane.getScene().getWindow();
    stage.setFullScreen(true);
}
 
Example 17
Source File: Game2048.java    From util4j with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param primaryStage
 */
@Override
public void start(Stage primaryStage) {
    gameManager = new GameManager();
    gameBounds = gameManager.getLayoutBounds();

    StackPane root = new StackPane(gameManager);
    root.getStyleClass().addAll("game-root");
    ChangeListener<Number> resize = (ov, v, v1) -> {
        double scale = Math.min((root.getWidth() - MARGIN) / gameBounds.getWidth(), (root.getHeight() - MARGIN) / gameBounds.getHeight());
        gameManager.setScale(scale);
        gameManager.setLayoutX((root.getWidth() - gameBounds.getWidth()) / 2d);
        gameManager.setLayoutY((root.getHeight() - gameBounds.getHeight()) / 2d);
    };
    root.widthProperty().addListener(resize);
    root.heightProperty().addListener(resize);

    Scene scene = new Scene(root);
    scene.getStylesheets().add(CSS);
    addKeyHandler(scene);
    addSwipeHandlers(scene);

    if (isARMDevice()) {
        primaryStage.setFullScreen(true);
        primaryStage.setFullScreenExitHint("");
    }

    if (Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) {
        scene.setCursor(Cursor.NONE);
    }

    Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
    double factor = Math.min(visualBounds.getWidth() / (gameBounds.getWidth() + MARGIN),
            visualBounds.getHeight() / (gameBounds.getHeight() + MARGIN));
    primaryStage.setTitle("2048FX");
    primaryStage.setScene(scene);
    primaryStage.setMinWidth(gameBounds.getWidth() / 2d);
    primaryStage.setMinHeight(gameBounds.getHeight() / 2d);
    primaryStage.setWidth((gameBounds.getWidth() + MARGIN) * factor);
    primaryStage.setHeight((gameBounds.getHeight() + MARGIN) * factor);
    primaryStage.show();
}
 
Example 18
Source File: UndecoratorController.java    From DevToolBox with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void setFullScreen(boolean value) {
    Stage stage = undecorator.getStage();
    stage.setFullScreen(value);
}