javafx.stage.Stage Java Examples
The following examples show how to use
javafx.stage.Stage.
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: DrawingApp.java From FXTutorials with MIT License | 7 votes |
@Override public void start(Stage stage) throws Exception { Scene scene = new Scene(createContent()); scene.setOnKeyReleased(e -> { if (e.getCode() == KeyCode.ENTER) { saveScreenshot(scene); } }); stage.setScene(scene); stage.show(); }
Example #2
Source File: FoxEatsDemo.java From htm.java-examples with GNU Affero General Public License v3.0 | 6 votes |
@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 #3
Source File: Gui.java From addressbook-level25 with MIT License | 6 votes |
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 #4
Source File: App.java From Notebook with Apache License 2.0 | 6 votes |
@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 #5
Source File: HelloFX.java From client-samples with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #6
Source File: HeatMapTest.java From charts with Apache License 2.0 | 6 votes |
@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 #7
Source File: GuiMainPreloader.java From BlockMap with MIT License | 6 votes |
@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 #8
Source File: Exercise_14_03.java From Intro-to-Java-Programming with MIT License | 6 votes |
@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 #9
Source File: PCGenPreloader.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
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 #10
Source File: Main.java From Everest with Apache License 2.0 | 6 votes |
@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 #11
Source File: TestPencilArcStyle.java From latexdraw with GNU General Public License v3.0 | 6 votes |
@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 #12
Source File: WindowTitle.java From marathonv5 with Apache License 2.0 | 6 votes |
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 #13
Source File: GlobalUI.java From SONDY with GNU General Public License v3.0 | 6 votes |
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 #14
Source File: FroggerApp.java From FXTutorials with MIT License | 6 votes |
@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 #15
Source File: StageControllerImpl.java From scenic-view with GNU General Public License v3.0 | 6 votes |
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 #16
Source File: Main.java From java_fx_node_link_demo with The Unlicense | 6 votes |
@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 #17
Source File: StudentDetailController.java From Hostel-Management-System with MIT License | 6 votes |
@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 #18
Source File: LibraryAssistantUtil.java From Library-Assistant with Apache License 2.0 | 6 votes |
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 #19
Source File: TestHandFreeHandStyle.java From latexdraw with GNU General Public License v3.0 | 6 votes |
@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 #20
Source File: TestShapeDeleter.java From latexdraw with GNU General Public License v3.0 | 6 votes |
@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 #21
Source File: NewVitaminWizardController.java From BowlerStudio with GNU General Public License v3.0 | 6 votes |
@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 #22
Source File: LineChartSample.java From StockInference-Spark with Apache License 2.0 | 6 votes |
@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 #23
Source File: Launch.java From JavaFX-Tutorial-Codes with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("FXML.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Round Buttons"); stage.show(); }
Example #24
Source File: AlarmApp.java From FXTutorials with MIT License | 5 votes |
@Override public void start(Stage stage) throws Exception { FXMLLoader loader = new FXMLLoader(getClass().getResource("ui.fxml")); AlarmController controller = new AlarmController(new AlarmModel()); loader.setController(controller); stage.setScene(new Scene(loader.load())); stage.setOnCloseRequest(e -> controller.onExit()); stage.setTitle("Alarm"); stage.setResizable(false); stage.show(); }
Example #25
Source File: PreferenceOutputPaneTest.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override public void start(Stage stage) { PreferenceRadioButton smartRadio = new PreferenceRadioButton(BooleanUserPreference.SMART_OUTPUT, "radio", false, userContext); smartRadio.setId("smartRadio"); PreferenceCheckBox compressionEnabled = new PreferenceCheckBox(BooleanUserPreference.PDF_COMPRESSION_ENABLED, "compression", true, userContext); compressionEnabled.setId("compressionEnabled"); PreferenceOutputPane victim = new PreferenceOutputPane(smartRadio, compressionEnabled); victim.setId("victim"); Scene scene = new Scene(new HBox(victim)); stage.setScene(scene); stage.show(); }
Example #26
Source File: Generator.java From jsilhouette with Apache License 2.0 | 5 votes |
private GridPane regular_polygon(Stage stage) { stage.setTitle("RegularPolygon"); GridPane grid = grid(); grid.add(new RegularPolygon(50, 50, 50, 3).getShape(), 0, 0); grid.add(new RegularPolygon(50, 50, 50, 4).getShape(), 1, 0); grid.add(new RegularPolygon(50, 50, 50, 5).getShape(), 2, 0); grid.add(new RegularPolygon(50, 50, 50, 6).getShape(), 3, 0); grid.add(new RegularPolygon(50, 50, 50, 7).getShape(), 4, 0); grid.add(new RegularPolygon(50, 50, 50, 8).getShape(), 5, 0); return grid; }
Example #27
Source File: Exercise_15_01.java From Intro-to-Java-Programming with MIT License | 5 votes |
@Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a VBox VBox vBox = new VBox(); vBox.setAlignment(Pos.CENTER); vBox.setPadding(new Insets(5, 5, 5, 5)); // Create a HBox HBox hBox = new HBox(5); hBox.setAlignment(Pos.CENTER); hBox.setPadding(new Insets(5, 5, 5, 5)); getCards(hBox); // Create a button Button btRefresh = new Button("Refresh"); // Process events btRefresh.setOnAction(e -> getCards(hBox)); // Place nodes in vbox vBox.getChildren().addAll(hBox, btRefresh); // Create a scene and place it in the stage Scene scene = new Scene(vBox); primaryStage.setTitle("Exercise_15_01"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage }
Example #28
Source File: ScaleBarSample.java From arcgis-runtime-samples-java with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { // create stack pane and application scene StackPane stackPane = new StackPane(); Scene scene = new Scene(stackPane); // set title, size and scene to stage stage.setTitle("Scale Bar Sample"); stage.setWidth(800); stage.setHeight(700); stage.setScene(scene); stage.show(); // create a map view mapView = new MapView(); ArcGISMap map = new ArcGISMap(Basemap.Type.IMAGERY, 64.1405, -16.2426, 16); mapView.setMap(map); // create a scale bar for the map view Scalebar scaleBar = new Scalebar(mapView); // specify skin style for the scale bar scaleBar.setSkinStyle(Scalebar.SkinStyle.GRADUATED_LINE); // set the unit system (default is METRIC) scaleBar.setUnitSystem(UnitSystem.IMPERIAL); // to enhance visibility of the scale bar, by making background transparent Color transparentWhite = new Color(1, 1, 1, 0.7); scaleBar.setBackground(new Background(new BackgroundFill(transparentWhite, new CornerRadii(5), Insets.EMPTY))); // add the map view and scale bar to stack pane stackPane.getChildren().addAll(mapView, scaleBar); // set position of scale bar StackPane.setAlignment(scaleBar, Pos.BOTTOM_CENTER); // give padding to scale bar StackPane.setMargin(scaleBar, new Insets(0, 0, 50, 0)); }
Example #29
Source File: RefundController.java From HealthPlus with Apache License 2.0 | 5 votes |
@FXML private void getRefundInfo() { Refund refund = (Refund)refundTable.getSelectionModel().getSelectedItem(); TablePosition pos = refundTable.getFocusModel().getFocusedCell(); int column = pos.getColumn(); if (column == 5) { info.setText("refund " + refund.getPatientID()); Stage stage = new Stage(); PopupAskController popup = new PopupAskController(info,cashier,this); popup.message(" Make the Refund?"); Scene scene = new Scene(popup); stage.setScene( scene ); Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds(); //set Stage boundaries to visible bounds of the main screen stage.setX(primaryScreenBounds.getMinX()); stage.setY(primaryScreenBounds.getMinY()); stage.setWidth(primaryScreenBounds.getWidth()); stage.setHeight(primaryScreenBounds.getHeight()); stage.initStyle(StageStyle.UNDECORATED); scene.setFill(null); stage.initStyle(StageStyle.TRANSPARENT); stage.show(); } if (info.getText().equals("1")) { System.out.println("Yes!"); } System.out.println(info.getText()); }
Example #30
Source File: AreaHeatMapTest.java From charts with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { StackPane pane = new StackPane(areaHeatMap); Scene scene = new Scene(pane); stage.setTitle("Area HeatMap"); stage.setScene(scene); stage.show(); }