Java Code Examples for javafx.stage.Stage.setScene()

The following are Jave code examples for showing how to use setScene() of the javafx.stage.Stage class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: fwm   File: HotkeyController.java   View Source Code Vote up 10 votes
public void start(Stage primaryStage, ScrollPane rootLayout) throws Exception {
	primaryStage.setTitle("Change Hotkeys");
	Scene myScene = new Scene(rootLayout);
	ourStage = primaryStage;
	myScene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
		public void handle(KeyEvent event) {
			if (changeHotkey) {
				if (addHotkey(event, changeHotkeyFunction)) {
					changeHotkey = false;
				}
			}
		}
	});
	Label divider = new Label();
	HBox labelHbox = new HBox(divider);
	divider.setText("----These hotkeys are not changeable----");
	labelHbox.setAlignment(Pos.CENTER);
	for (String key : HOTKEYS) {
		hotkeyVBox.getChildren().add(hotkeys.get(key).getHotkeyHBox());
	}
	hotkeyVBox.getChildren().add(labelHbox);
	for (ImmutableHotkey hotkey : IMMUTABLE_HOTKEYS) {
		hotkeyVBox.getChildren().add(hotkey.getHotkeyHBox());
	}
	primaryStage.setScene(myScene);
}
 
Example 2
Project: Projeto-IP2   File: CadastroProfessor.java   View Source Code Vote up 7 votes
public void start(Stage primaryStage) throws Exception {
	
	//Essa parte foi para apenas escrever algo no arquivo de disciplinas, para testar.
	//se a parte disciplina aptas da GUI estava certa.
	//Disciplina dis = new Disciplina("´┐Żlgebra ", 23);
	//DisciplinaController.getInstance().cadastrarDisciplina(dis);
	//.........................
	primaryStage.setTitle("Cadastro de Professores");
	pane = FXMLLoader.load(this.getClass().getResource("cadastroProfessorFXML.fxml"));
	menu = (MenuButton) pane.getChildren().get(8);
	adiciona();
	primaryStage.setScene(new Scene(pane));
	primaryStage.setResizable(false);
	primaryStage.show();
	
}
 
Example 3
Project: spring2017java   File: AnimationDemoSection3.java   View Source Code Vote up 7 votes
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
    
    Scene scene = new Scene(root);
    
    stage.setScene(scene);
    stage.show();
}
 
Example 4
Project: Money-Manager   File: GoToOperation.java   View Source Code Vote up 7 votes
public void goToCashCalculate(double positionX, double positionY) {
	try {
		Stage CashCalculateStage = new Stage();
		Parent root = FXMLLoader.load(getClass().getResource("/view/CashCalculate.fxml"));
		Scene scene = new Scene(root,800,550);
		CashCalculateStage.setScene(scene);
		CashCalculateStage.setResizable(false);
		CashCalculateStage.getIcons().add(new Image(getClass().getResourceAsStream("/imges/purse.png")));
		CashCalculateStage.setTitle("Cash Calculate");
		CashCalculateStage.setX(positionX);
		CashCalculateStage.setY(positionY);
		CashCalculateStage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 5
Project: symmetrical-memory   File: MainForm.java   View Source Code Vote up 7 votes
@Override
public void start(Stage stage) throws Exception {
	FXMLLoader loader = new FXMLLoader(getClass().getResource("/ph/kana/memory/ui/fxml/main-form.fxml"));
	Scene scene = new Scene(loader.load());

	setUserAgentStylesheet(STYLESHEET_MODENA);

	stage.setWidth(APP_WIDTH);
	stage.setMinWidth(APP_WIDTH);

	stage.setHeight(APP_HEIGHT);
	stage.setMinHeight(APP_HEIGHT);

	stage.setTitle("kana0011/password-locker");
	stage.setScene(scene);

	MainFormController controller = loader.<MainFormController>getController();
	controller.setHostServices(getHostServices());

	stage.show();
}
 
Example 6
Project: osrs-data-converter   File: App.java   View Source Code Vote up 7 votes
@Override
public void start(Stage stage) {
	App.stage = stage;
	try {
		Parent root = FXMLLoader.load(App.class.getResource("/ui/Main.fxml"));
		Scene scene = new Scene(root);
		scene.getStylesheets().add(getClass().getResource("/style.css").toExternalForm());
		stage.setTitle("OSRS Data To 317 Converter");		
		stage.centerOnScreen();
		stage.setResizable(false);
		stage.sizeToScene();
		stage.initStyle(StageStyle.UNDECORATED);
		stage.setScene(scene);	
		stage.getIcons().add(new Image(App.class.getResourceAsStream("/icons/icon.png")));
		stage.show();
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 7
Project: charts   File: ChartTest.java   View Source Code Vote up 7 votes
@Override public void start(Stage stage) {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(10));
    gridPane.setHgap(10);
    gridPane.setVgap(10);
    gridPane.add(lineChart, 0, 0);
    gridPane.add(areaChart, 1, 0);
    gridPane.add(smoothLineChart, 0, 1);
    gridPane.add(smoothAreaChart, 1, 1);
    gridPane.add(scatterChart, 0, 2);
    gridPane.add(donutChart, 1, 2);

    Scene scene = new Scene(new StackPane(gridPane));

    stage.setTitle("Charts");
    stage.setScene(scene);
    stage.show();

    timer.start();

    modificationThread.start();
}
 
Example 8
Project: java-solitaire   File: root.java   View Source Code Vote up 6 votes
@FXML protected void freecellMenuClick() throws IOException {
	Stage main = (Stage) _gameMenu.getScene().getWindow();
	Parent freecellFXML = FXMLLoader.load(getClass().getResource("/fxml/freecellGame.fxml"));
	freecellFXML.getStylesheets().add("/stylesheets/freecellGame.css");
	Scene freecellScene = new Scene(freecellFXML);
	main.setOnCloseRequest(b -> {
		boolean response = ExitWindow.display("Confirm", "Are you sure you want to quit now?");
		if(response) main.close();
		b.consume();
	});
	main.setScene(freecellScene);
	main.show();
}
 
Example 9
Project: marathonv5   File: DirectoryChooserSample.java   View Source Code Vote up 6 votes
@Override public void start(final Stage stage) {
    stage.setTitle("Directory Chooser Sample");

    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final Button openButton = new Button("Select a folder...");

    openButton.setOnAction((final ActionEvent e) -> {
        File file = directoryChooser.showDialog(stage);
        if (file != null) {
            openFile(file);
        }
    });

    final GridPane inputGridPane = new GridPane();

    GridPane.setConstraints(openButton, 0, 1);
    inputGridPane.setHgap(6);
    inputGridPane.setVgap(6);
    inputGridPane.getChildren().addAll(openButton);

    final Pane rootGroup = new VBox(12);
    rootGroup.getChildren().addAll(inputGridPane);
    rootGroup.setPadding(new Insets(12, 12, 12, 12));

    stage.setScene(new Scene(rootGroup));
    stage.show();
}
 
Example 10
Project: Orsum-occulendi   File: Controller.java   View Source Code Vote up 6 votes
/**
 * Zeigt den Connect-Dialog an
 * @param e	Das Event
 */
public void presentConnectToServerWindow(Event e) {
	try {
		FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("connectToServer.fxml"));
		GridPane root = (GridPane)loader.load();
		connectToServerController = loader.getController();

		connectToServerController.setCompletedRunnable((run) -> {
			/*String ip = connectToServerController.getIpAdressTextField().getText();
			String port = connectToServerController.getPortTextField().getText();*/
			String ip = (String) UserDefaults.sharedDefaults().valueForKey(UserDefaults.ADRESS_KEY);
			int port = (int) UserDefaults.sharedDefaults().valueForKey(UserDefaults.PORT_KEY);
			String userID = (String)UserDefaults.sharedDefaults().valueForKey(UserDefaults.NAME_KEY);

			this.client = new Client(ip, port, userID);
			this.client.setDelegate(this);
			this.client.connect();

			connectToServerCallback = run;
		});

           connectToServerStage = new Stage();
           connectToServerStage.setResizable(false);
           connectToServerStage.setTitle("Connect to server");
           connectToServerStage.setScene(new Scene(root));
           connectToServerStage.show();
	} catch (IOException e1) {
		e1.printStackTrace();
	}
}
 
Example 11
Project: marathonv5   File: TreeTableSampleApp.java   View Source Code Vote up 6 votes
@Override public void start(Stage primaryStage) {
    primaryStage.setTitle("TreeTable View Sample");
    primaryStage.setScene(new Scene(new TreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 12
Project: util4j   File: Game2048.java   View Source Code Vote up 6 votes
/**
 *
 * @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 13
Project: LivroJavaComoProgramar10Edicao   File: ColorChooser.java   View Source Code Vote up 6 votes
@Override
public void start(Stage stage) throws Exception 
{
   Parent root = 
      FXMLLoader.load(getClass().getResource("ColorChooser.fxml"));
   
   Scene scene = new Scene(root);
   stage.setTitle("Color Chooser");
   stage.setScene(scene);
   stage.show();
}
 
Example 14
Project: cassandra-client   File: CassandraClientGUI.java   View Source Code Vote up 6 votes
@Override
public void start(Stage primaryStage) throws Exception {
    view.setPrimaryStage(primaryStage);

    primaryStage.setTitle("Cassandra client");
    primaryStage.getIcons().add(new Image("cassandra_ico.png"));
    primaryStage.setScene(new Scene(view.getView()));
    primaryStage.setResizable(true);
    primaryStage.centerOnScreen();
    primaryStage.show();

    ((MainController) view.getController()).onWindowLoad();
}
 
Example 15
Project: Calculadora-JavaFx   File: Calculadora.java   View Source Code Vote up 6 votes
@Override
public void start(Stage primaryStage) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("view.fxml"));
    
    primaryStage.setScene(new Scene(root));
    primaryStage.show();
}
 
Example 16
Project: CBM-Changes-Explorer   File: Main.java   View Source Code Vote up 6 votes
@Override
public void start(Stage primaryStage) throws Exception {
  Parent root = FXMLLoader.load(getClass().getResource("/main.fxml"));
  primaryStage.setTitle("Couchbase Mobile Changes Explorer");
  primaryStage.setScene(new Scene(root, 800, 300));
  primaryStage.show();
}
 
Example 17
Project: AquamarineLake   File: Main.java   View Source Code Vote up 6 votes
@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
    primaryStage.setTitle("Hello World");
    primaryStage.setScene(new Scene(root, 600, 400));
    primaryStage.setResizable(false);
    primaryStage.sizeToScene();
    primaryStage.show();
}
 
Example 18
Project: boutique-de-jus   File: BoutiqueDeJusBootstrap.java   View Source Code Vote up 5 votes
@Override
public void start(final Stage stage) throws Exception {

    this.com.start();
    this.consolePipe.open();
    this.processManager.start();

    stage.setTitle("Boutique-de-jus Bootstrap Control");
    stage.initStyle(StageStyle.DECORATED);

    FXMLLoader loader = new FXMLLoader(getClass().getResource("/main.fxml"));
    loader.setControllerFactory((c) -> {
        try {
            Object controller = c.newInstance();
            if (ProcessController.class.isAssignableFrom(c)) {
                ((ProcessController) controller).setup(this.com,
                                                       this.consolePipe,
                                                       this.scheduler,
                                                       this.processManager);
            }
            return controller;
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    });

    TabPane tabPane = loader.load();

    Scene scene = new Scene(tabPane, 1024, 768, Color.AQUA);
    scene.getStylesheets().add(getClass().getResource("/style.css").toExternalForm());
    stage.setScene(scene);
    stage.show();

    /*
    Notifications.create()
                 .title("Achievement unlocked")
                 .text("Bring up a Desktop Notification!")
                 .hideAfter(Duration.seconds(2))
                 .showWarning();
                 */
}
 
Example 19
Project: Java-Data-Science-Made-Easy   File: MainApp - Simple Regression.java   View Source Code Vote up 5 votes
@Override
    public void start(Stage stage) {

//Belgium	1950	8639369
//Belgium	1960	9118700
//Belgium	1970	9637800
//Belgium	1980	9846800
//Belgium	1990	9969310
//Belgium	2000	10263618
        double[][] input = {
            {1950, 8639369},
            {1960, 9118700},
            {1970, 9637800},
            {1980, 9846800},
            {1990, 9969310},
            {2000, 10263618}};
        double[] predictionYears = {1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020, 2030, 2040};

        NumberFormat yearFormat = NumberFormat.getNumberInstance();
        yearFormat.setMaximumFractionDigits(0);
        yearFormat.setGroupingUsed(false);
        NumberFormat populationFormat = NumberFormat.getNumberInstance();
        populationFormat.setMaximumFractionDigits(0);
        
        SimpleRegression regression = new SimpleRegression();
        regression.addData(input);
        projectedSeries.setName("Projected");
        for (int i = 0; i < predictionYears.length; i++) {
            out.println(yearFormat.format(predictionYears[i]) + "-"
                    + populationFormat.format(regression.predict(predictionYears[i])));
            addDataItem(projectedSeries, predictionYears[i],
                    regression.predict(predictionYears[i]));
        }

        displayAttribute("Slope",regression.getSlope());
        displayAttribute("Intercept", regression.getIntercept());
        displayAttribute("InterceptStdEr", regression.getInterceptStdErr());
        displayAttribute("MeanSquareError", regression.getMeanSquareError());
        displayAttribute("N", + regression.getN());
        displayAttribute("R", + regression.getR());
        displayAttribute("RSquare", regression.getRSquare());

        //Create index chart
        stage.setTitle("Simple Linear Regression");
        xAxis.setTickLabelFormatter(new StringConverter<Number>() {
            @Override
            public String toString(Number object) {
                return (object.intValue()) + "";
            }

            @Override
            public Number fromString(String string) {
                return 0;
            }
        });

        final LineChart<Number, Number> lineChart
                = new LineChart<>(xAxis, yAxis);
        lineChart.setTitle("Belgium Population");
        yAxis.setLabel("Population");

        originalSeries.setName("Actual");
        addDataItem(originalSeries, 1950, 8639369);
        addDataItem(originalSeries, 1960, 9118700);
        addDataItem(originalSeries, 1970, 9637800);
        addDataItem(originalSeries, 1980, 9846800);
        addDataItem(originalSeries, 1990, 9969310);
        addDataItem(originalSeries, 2000, 10263618);

        Scene scene = new Scene(lineChart, 800, 600);
        lineChart.getData().addAll(originalSeries, projectedSeries);
        stage.setScene(scene);
        stage.show();
    }
 
Example 20
Project: marathonv5   File: CheckBoxTreeViewApp.java   View Source Code Vote up 5 votes
@Override public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Check Box TreeView");
    primaryStage.setScene(new Scene(new CheckBoxTreeViewSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
}