Java Code Examples for javafx.stage.Stage

The following examples show how to use javafx.stage.Stage. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Hostel-Management-System   Source File: StudentDetailController.java    License: MIT License 6 votes vote down vote up
@FXML
private void viewPayBillAction(ActionEvent event)
{
    MainProgramSceneController.mainTopAnchorPane.setEffect(new BoxBlur());
    billStage = new Stage();
    billStage.setOnCloseRequest(new EventHandler<WindowEvent>()
    {
        @Override
        public void handle(WindowEvent t)
        {
            MainProgramSceneController.mainTopAnchorPane.effectProperty().setValue(null);
        }
    });
    billStage.setTitle("View And Pay Due Bills");
    billStage.initModality(Modality.APPLICATION_MODAL);
    billStage.initStyle(StageStyle.UTILITY);
    billStage.setResizable(false);
    try
    {
        Parent passwordParent = FXMLLoader.load(getClass().getResource("viewPayBill.fxml"));
        billStage.setScene(new Scene(passwordParent));
        billStage.show();
    } catch (IOException ex)
    {
    }
}
 
Example 2
Source Project: java_fx_node_link_demo   Source File: Main.java    License: The Unlicense 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	BorderPane root = new BorderPane();
	
	try {
		
		Scene scene = new Scene(root,640,480);
		scene.getStylesheets().add(getClass().getResource("/application.css").toExternalForm());
		primaryStage.setScene(scene);
		primaryStage.show();
		
	} catch(Exception e) {
		e.printStackTrace();
	}
	
	root.setCenter(new RootLayout());
}
 
Example 3
public void placeStage(final Stage stage) {
    if (targetWindow != null) {
        stage.setX(targetWindow.getX() + targetWindow.getWidth());
        stage.setY(targetWindow.getY());
        try {
            // Prevents putting the stage out of the screen
            final Screen primary = Screen.getPrimary();
            if (primary != null) {
                final Rectangle2D rect = primary.getVisualBounds();
                if (stage.getX() + stage.getWidth() > rect.getMaxX()) {
                    stage.setX(rect.getMaxX() - stage.getWidth());
                }
                if (stage.getY() + stage.getHeight() > rect.getMaxY()) {
                    stage.setX(rect.getMaxY() - stage.getHeight());
                }
            }
        } catch (final Exception e) {
            ExceptionLogger.submitException(e);
        }
    }
}
 
Example 4
Source Project: pcgen   Source File: PCGenPreloader.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public PCGenPreloader()
{
	GuiAssertions.assertIsNotOnGUIThread();
	loader.setLocation(getClass().getResource("PCGenPreloader.fxml"));
	Platform.runLater(() -> {
		primaryStage = new Stage();
		final Scene scene;
		try
		{
			scene = loader.load();
		} catch (IOException e)
		{
			Logging.errorPrint("failed to load preloader", e);
			return;
		}

		primaryStage.setScene(scene);
		primaryStage.show();
	});
}
 
Example 5
Source Project: Intro-to-Java-Programming   Source File: Exercise_14_03.java    License: MIT License 6 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a list of card numbers
	ArrayList<Integer> cards = getCards();
	// Create a HBox pane
	HBox pane = new HBox(5);
	pane.setPadding(new Insets(5, 5, 5, 5));

	// Add nodes to pane
	for (int i = 0; i < 3; i++) {
		pane.getChildren().add(new ImageView(new Image("image/card/" +
			cards.get(i) + ".png")));
	}

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_14_03"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 6
Source Project: BlockMap   Source File: GuiMainPreloader.java    License: MIT License 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
	splashScreen = stage;
	stage.centerOnScreen();
	stage.initStyle(StageStyle.TRANSPARENT);
	stage.getIcons().add(new Image(getClass().getResourceAsStream("icon.png")));
	ImageView icon = new ImageView(getClass().getResource("icon.png").toString());
	icon.setFitWidth(SPLASH_WIDTH);
	icon.setPreserveRatio(true);
	BorderPane parent = new BorderPane(icon);
	parent.setBackground(Background.EMPTY);
	Scene scene = new Scene(parent, SPLASH_WIDTH, SPLASH_HEIGHT);
	scene.setFill(Color.TRANSPARENT);

	splashScreen.setScene(scene);
	splashScreen.show();
}
 
Example 7
Source Project: addressbook-level25   Source File: Gui.java    License: MIT License 6 votes vote down vote up
private MainWindow createMainWindow(Stage stage, Stoppable mainApp) throws IOException{
    FXMLLoader loader = new FXMLLoader();

    /* Note: When calling getResource(), use '/', instead of File.separator or '\\'
     * More info: http://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html#res_name_context
     */
    loader.setLocation(Main.class.getResource("ui/mainwindow.fxml"));

    stage.setTitle(version);
    stage.setScene(new Scene(loader.load(), INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT));
    stage.show();
    MainWindow mainWindow = loader.getController();
    mainWindow.setLogic(logic);
    mainWindow.setMainApp(mainApp);
    return mainWindow;
}
 
Example 8
Source Project: Notebook   Source File: App.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	try {
		Scene scene = new Scene(new LoginView().getView());
		scene.getStylesheets().add("css/application.css");

		primaryStage.setTitle(Constants.APP_NAME);
		primaryStage.setResizable(false);
		primaryStage.setScene(scene);
		primaryStage.getIcons().add(Constants.APP_LOGO);
		primaryStage.show();

		// createShortcut();

	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
Example 9
Source Project: Everest   Source File: Main.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    SettingsLoader settingsLoader = new SettingsLoader();
    settingsLoader.settingsLoaderThread.join();

    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/HomeWindow.fxml"));
    Parent homeWindow = loader.load();
    Stage dashboardStage = new Stage();
    ThemeManager.setTheme(homeWindow);

    Rectangle2D screenBounds = Screen.getPrimary().getBounds();
    dashboardStage.setWidth(screenBounds.getWidth() * 0.83);
    dashboardStage.setHeight(screenBounds.getHeight() * 0.74);

    dashboardStage.getIcons().add(new Image(getClass().getResource("/assets/Logo.png").toExternalForm()));
    dashboardStage.setScene(new Scene(homeWindow));
    dashboardStage.setTitle(APP_NAME);
    dashboardStage.show();
}
 
Example 10
Source Project: FXTutorials   Source File: FroggerApp.java    License: MIT License 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    stage.setScene(new Scene(createContent()));

    stage.getScene().setOnKeyPressed(event -> {
        switch (event.getCode()) {
            case W:
                frog.setTranslateY(frog.getTranslateY() - 40);
                break;
            case S:
                frog.setTranslateY(frog.getTranslateY() + 40);
                break;
            case A:
                frog.setTranslateX(frog.getTranslateX() - 40);
                break;
            case D:
                frog.setTranslateX(frog.getTranslateX() + 40);
                break;
            default:
                break;
        }
    });

    stage.show();
}
 
Example 11
Source Project: latexdraw   Source File: TestShapeDeleter.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Injector createInjector() {
	return new ShapePropInjector() {
		@Override
		protected void configure() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
			super.configure();
			bindToSupplier(Stage.class, () -> stage);
			bindToInstance(Border.class, Mockito.mock(Border.class));
			bindToInstance(CanvasController.class, Mockito.mock(CanvasController.class));
			bindToInstance(TextSetter.class, Mockito.mock(TextSetter.class));
			bindAsEagerSingleton(FacadeCanvasController.class);
			bindAsEagerSingleton(Hand.class);
			bindAsEagerSingleton(ShapeDeleter.class);
			bindToInstance(Pencil.class, Mockito.mock(Pencil.class));
			bindToInstance(MetaShapeCustomiser.class, Mockito.mock(MetaShapeCustomiser.class));
			bindToInstance(ShapeTextCustomiser.class, Mockito.mock(ShapeTextCustomiser.class));
			bindToInstance(ShapePlotCustomiser.class, Mockito.mock(ShapePlotCustomiser.class));
		}
	};
}
 
Example 12
@Override
public void start(Stage stage) throws Exception {
    Application.Parameters params = getParameters();
    List<String> paramList = params.getUnnamed();

    // Check for the existence of a proper API Key
    if(paramList.size() < 1 || !paramList.get(0).startsWith("-K")) {
        throw new IllegalStateException("Demo must be started with arguments [-K]<your-api-key>");
    }

    FoxEatsDemoView view = new FoxEatsDemoView(this, params);
    Scene scene = new Scene(view, 900, 600, Color.WHITE);
    stage.setScene(scene);
    stage.show();

    Rectangle2D primScreenBounds = Screen.getPrimary(). getVisualBounds();
    stage.setX(( primScreenBounds.getWidth() - stage.getWidth()) / 2);
    stage.setY(( primScreenBounds.getHeight() - stage.getHeight()) / 4);

}
 
Example 13
Source Project: StockInference-Spark   Source File: LineChartSample.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override public void start(Stage stage) {
    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis(20,250,1);
    
    final LineChart lineChart = new LineChart(
            xAxis, yAxis,
            FXCollections.observableArrayList(
                    new XYChart.Series(
                            "My portfolio",
                            FXCollections.observableArrayList(
                                    plot(23, 14, 15, 24, 34, 36, 22, 45, 43, 17, 29, 25)
                            )
                    )
            )
    );
    lineChart.setCursor(Cursor.CROSSHAIR);
    lineChart.setTitle("Stock Monitoring, 2013");


    stage.setScene(new Scene(lineChart, 500, 400));
    stage.show();
  
}
 
Example 14
@Override
public void start(Stage primaryStage) throws Exception {
	FXMLLoader loader = AssetFactory.loadLayout("layout/newVitaminWizard.fxml",true);
	Parent root;
	//loader.setController(this);
	// This is needed when loading on MAC
	loader.setClassLoader(getClass().getClassLoader());
	root = loader.load();
	Platform.runLater(() -> {
		primaryStage.setTitle("Edit Vitamins Wizard");

		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.initModality(Modality.WINDOW_MODAL);
		primaryStage.setResizable(true);
		primaryStage.show();
	});
}
 
Example 15
Source Project: Library-Assistant   Source File: LibraryAssistantUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void initPDFExprot(StackPane rootPane, Node contentPane, Stage stage, List<List> data) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save as PDF");
    FileChooser.ExtensionFilter extFilter
            = new FileChooser.ExtensionFilter("PDF files (*.pdf)", "*.pdf");
    fileChooser.getExtensionFilters().add(extFilter);
    File saveLoc = fileChooser.showSaveDialog(stage);
    ListToPDF ltp = new ListToPDF();
    boolean flag = ltp.doPrintToPdf(data, saveLoc, ListToPDF.Orientation.LANDSCAPE);
    JFXButton okayBtn = new JFXButton("Okay");
    JFXButton openBtn = new JFXButton("View File");
    openBtn.setOnAction((ActionEvent event1) -> {
        try {
            Desktop.getDesktop().open(saveLoc);
        } catch (Exception exp) {
            AlertMaker.showErrorMessage("Could not load file", "Cant load file");
        }
    });
    if (flag) {
        AlertMaker.showMaterialDialog(rootPane, contentPane, Arrays.asList(okayBtn, openBtn), "Completed", "Member data has been exported.");
    }
}
 
Example 16
public void start(Stage stage) {
    String javaVersion = System.getProperty("java.version");
    String javafxVersion = System.getProperty("javafx.version");
    Label label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");

    ImageView imageView = new ImageView(new Image(HelloFX.class.getResourceAsStream("/hellofx/openduke.png")));
    imageView.setFitHeight(200);
    imageView.setPreserveRatio(true);

    VBox root = new VBox(30, imageView, label);
    root.setAlignment(Pos.CENTER);
    Scene scene = new Scene(root, 640, 480);
    scene.getStylesheets().add(HelloFX.class.getResource("styles.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
 
Example 17
Source Project: charts   Source File: HeatMapTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(heatMap);

    // Setup a mouse event filter which adds spots to the heatmap as soon as the mouse will be moved across the pane
    pane.addEventFilter(MouseEvent.MOUSE_MOVED, event -> {
        double x = event.getX();
        double y = event.getY();
        if (x < heatMap.getSpotRadius()) x = heatMap.getSpotRadius();
        if (x > pane.getWidth() - heatMap.getSpotRadius()) x = pane.getWidth() - heatMap.getSpotRadius();
        if (y < heatMap.getSpotRadius()) y = heatMap.getSpotRadius();
        if (y > pane.getHeight() - heatMap.getSpotRadius()) y = pane.getHeight() - heatMap.getSpotRadius();

        heatMap.addSpot(x, y);
    });
    pane.widthProperty().addListener((ov, oldWidth, newWidth) -> heatMap.setSize(newWidth.doubleValue(), pane.getHeight()));
    pane.heightProperty().addListener((ov, oldHeight, newHeight) -> heatMap.setSize(pane.getWidth(), newHeight.doubleValue()));

    Scene scene = new Scene(pane, 400, 400);

    stage.setTitle("HeatMap (move mouse over pane)");
    stage.setScene(scene);
    stage.show();
}
 
Example 18
Source Project: latexdraw   Source File: TestPencilArcStyle.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Injector createInjector() {
	return new ShapePropInjector() {
		@Override
		protected void configure() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
			super.configure();
			bindToSupplier(Stage.class, () -> stage);
			hand = mock(Hand.class);
			bindToInstance(Hand.class, hand);
			bindToInstance(TextSetter.class, mock(TextSetter.class));
			bindAsEagerSingleton(Pencil.class);
			bindAsEagerSingleton(ShapeArcCustomiser.class);
			bindToInstance(MetaShapeCustomiser.class, mock(MetaShapeCustomiser.class));
		}
	};
}
 
Example 19
Source Project: marathonv5   Source File: WindowTitle.java    License: Apache License 2.0 6 votes vote down vote up
public String getTitle() {
    String title = getTitle(window);
    ObservableList<Stage> windows = JavaCompatibility.getStages();
    String original = title;
    int index = 1;
    for (Stage w : windows) {
        if (w == window) {
            return title;
        }
        if (!w.isShowing()) {
            continue;
        }
        String wTitle = getTitle(w);
        if (original.equals(wTitle)) {
            title = original + "(" + index++ + ")";
        }
    }
    return title;
}
 
Example 20
Source Project: SONDY   Source File: GlobalUI.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void about(){
    final Stage stage = new Stage();
    stage.setResizable(false);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initStyle(StageStyle.UTILITY);
    stage.setTitle("About SONDY");
    WebView webView = new WebView();
    webView.getEngine().loadContent(getReferences());
    webView.setMaxWidth(Main.columnWidthLEFT);
    webView.setMinWidth(Main.columnWidthLEFT);
    webView.setMaxHeight(Main.columnWidthLEFT);
    webView.setMinHeight(Main.columnWidthLEFT);
    Scene scene = new Scene(VBoxBuilder.create().children(new Label("SONDY "+Main.version),new Label("Main developper: Adrien Guille <[email protected]>"),webView).alignment(Pos.CENTER).padding(new Insets(10)).spacing(3).build());
    scene.getStylesheets().add("resources/fr/ericlab/sondy/css/GlobalStyle.css");
    stage.setScene(scene);
    stage.show();
}
 
Example 21
@Override
protected Injector createInjector() {
	return new ShapePropInjector() {
		@Override
		protected void configure() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
			super.configure();
			bindToSupplier(Stage.class, () -> stage);
			pencil = mock(Pencil.class);
			bindToInstance(Pencil.class, pencil);
			bindToInstance(TextSetter.class, mock(TextSetter.class));
			bindAsEagerSingleton(Hand.class);
			bindAsEagerSingleton(ShapeFreeHandCustomiser.class);
			bindToInstance(MetaShapeCustomiser.class, mock(MetaShapeCustomiser.class));
		}
	};
}
 
Example 22
Source Project: samples   Source File: HelloFX.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) {
    String javaVersion = System.getProperty("java.version");
    String javafxVersion = System.getProperty("javafx.version");
    Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
    Scene scene = new Scene(new StackPane(l), 640, 480);
    stage.setScene(scene);
    stage.show();
}
 
Example 23
@Override
public void start(Stage primaryStage) throws Exception {

    if( logger.isDebugEnabled() ) {
        logger.debug("[START]");
    }

    Injector injector = Guice.createInjector(new OldScoresModule());

    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml2/MainView.fxml"),
                                       null,
                                       injector.getInstance(BuilderFactory.class),
                                       injector.getInstance(GuiceControllerFactory.class));

    Parent p = loader.load();
    MainViewController mv = loader.getController();

    Scene scene = new Scene( p );

    scene.setOnKeyPressed(evt -> {

        if( evt.getCode().equals(KeyCode.F1) ) {
            try {
                if( logger.isDebugEnabled() ) {
                    logger.debug("[OPEN HELP]");
                }
                mv.openHelpDialog();
            } catch (IOException exc) {
                String msg = "error showing help dialog";
                logger.error(msg);
                Alert alert = new Alert(Alert.AlertType.ERROR, msg);
                alert.showAndWait();
            }
        }
    });

    primaryStage.setTitle("Old Scores");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 24
Source Project: marathonv5   Source File: CheckBoxTreeTableSampleApp.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("CheckBox TreeTable View Sample");
    primaryStage.setScene(new Scene(new CheckBoxTreeTableSample()));
    primaryStage.sizeToScene();
    primaryStage.show();
    TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
Example 25
Source Project: oim-fx   Source File: TestFrame.java    License: MIT License 5 votes vote down vote up
public void start(Stage primaryStage) {
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            System.out.println("Hello World!");
        }
    });

}
 
Example 26
Source Project: charts   Source File: LegendTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(legend);

    Scene scene = new Scene(pane);

    stage.setTitle("Legend");
    stage.setScene(scene);
    stage.show();
}
 
Example 27
Source Project: Augendiagnose   Source File: DialogUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a basic dialog window.
 *
 * @param fxmlString
 *            The FXML resource.
 *
 * @param decorated a flag indicating if the dialog should have OS border.
 * @return The dialog controller.
 */
private static DialogController createDialog(final String fxmlString, final boolean decorated) {
	DialogController controller;
	controller = (DialogController) FxmlUtil.getRootFromFxml(fxmlString);

	Scene scene = new Scene(controller.getRoot());
	Stage dialog = new Stage();
	dialog.initModality(Modality.WINDOW_MODAL);
	dialog.initStyle(decorated ? StageStyle.DECORATED : StageStyle.UNDECORATED);
	dialog.initOwner(Application.getStage());
	dialog.setScene(scene);
	controller.setStage(dialog);
	return controller;
}
 
Example 28
Source Project: marathonv5   Source File: HyperlinkWebViewSample.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    VBox vbox = new VBox();
    Scene scene = new Scene(vbox);
    stage.setTitle("Hyperlink Sample");
    stage.setWidth(570);
    stage.setHeight(550);

    selectedImage.setLayoutX(100);
    selectedImage.setLayoutY(10);

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    for (int i = 0; i < captions.length; i++) {
        final Hyperlink hpl = hpls[i] = new Hyperlink(captions[i]);
        final Image image = images[i] = new Image(getClass().getResourceAsStream(imageFiles[i]));
        hpl.setGraphic(new ImageView(image));
        hpl.setFont(Font.font("Arial", 14));
        final String url = urls[i];

        hpl.setOnAction((ActionEvent e) -> {
            webEngine.load(url);
        });
    }

    HBox hbox = new HBox();
    hbox.setAlignment(Pos.BASELINE_CENTER);
    hbox.getChildren().addAll(hpls);
    vbox.getChildren().addAll(hbox, browser);
    VBox.setVgrow(browser, Priority.ALWAYS);

    stage.setScene(scene);
    stage.show();
}
 
Example 29
Source Project: FXTutorials   Source File: MinesweeperApp.java    License: MIT License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    scene = new Scene(createContent());

    stage.setScene(scene);
    stage.show();
}
 
Example 30
Source Project: FXTutorials   Source File: GCApp.java    License: MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    primaryStage.setTitle("GC");
    primaryStage.setScene(scene);
    primaryStage.show();
}