Java Code Examples for javafx.scene.Scene
The following examples show how to use
javafx.scene.Scene. 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 check out the related API usage on the sidebar.
Example 1
Source Project: pcgen Source File: PCGenPreloader.java License: 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 2
Source Project: chart-fx Source File: DataSetMeasurementsTests.java License: Apache License 2.0 | 6 votes |
@Start public void start(Stage stage) { final XYChart chart = new XYChart(); chart.getDatasets().add(new SineFunction("sine1", 1000)); chart.getDatasets().add(new SineFunction("sine2", 1000)); plugin = new ParameterMeasurements(); for (MeasurementType type : MeasurementType.values()) { assertThrows(IllegalArgumentException.class, () -> new DataSetMeasurements(null, type).initialize()); assertDoesNotThrow(() -> new DataSetMeasurements(plugin, type)); } field = new DataSetMeasurements(plugin, MeasurementType.FFT_DB_RANGED); field.setDataSet(chart.getAllDatasets().get(0)); assertTrue(field.getMeasType().isVerticalMeasurement()); chart.getPlugins().add(plugin); final VBox root = new VBox(chart); stage.setScene(new Scene(root, 100, 100)); stage.show(); }
Example 3
Source Project: medusademo Source File: Test.java License: Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { StackPane pane = new StackPane(gauge); pane.setPadding(new Insets(10)); pane.setBackground(new Background(new BackgroundFill(Color.rgb(50, 50, 50), CornerRadii.EMPTY, Insets.EMPTY))); Scene scene = new Scene(pane); stage.setTitle("Test"); stage.setScene(scene); stage.show(); // Calculate number of nodes calcNoOfNodes(pane); System.out.println(noOfNodes + " Nodes in SceneGraph"); }
Example 4
Source Project: tornadofx-controls Source File: MultiSelectDemo.java License: Apache License 2.0 | 6 votes |
public void start(Stage stage) throws Exception { MultiSelect<Email> multiSelect = new MultiSelect<>(); multiSelect.setConverter(new StringConverter<Email>() { public String toString(Email object) { return object.getEmail(); } public Email fromString(String string) { return new Email(string, null); } }); multiSelect.getItems().addAll(addresses); stage.setScene(new Scene(multiSelect, 600, 400)); stage.show(); }
Example 5
Source Project: Enzo Source File: Demo.java License: Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { ImageView imgView = new ImageView(backgroundImage); PushButton button1 = PushButtonBuilder.create() .status(PushButton.Status.DESELECTED) .color(Color.CYAN) .prefWidth(128) .prefHeight(128) .build(); button1.setOnSelect(selectionEvent -> System.out.println("Select") ); button1.setOnDeselect(selectionEvent -> System.out.println("Deselect") ); StackPane pane = new StackPane(); pane.setPadding(new Insets(10, 10, 10, 10)); pane.getChildren().setAll(imgView, button1); Scene scene = new Scene(pane, 256, 256, Color.rgb(153, 153, 153)); stage.setTitle("JavaFX PushButton"); stage.setScene(scene); stage.show(); }
Example 6
Source Project: Image-Cipher Source File: WindowController.java License: Apache License 2.0 | 6 votes |
@Override public void start(Stage myStage) { Optional<Parent> root = Optional.empty(); try { root = Optional.of(FXMLLoader.load( Main.class.getResource("/views/MainWindow.fxml") )); } catch (IOException e) { logger.error(e); } root.ifPresent(parent -> { Scene scene = new Scene(parent); scene.getStylesheets().add("org/kordamp/bootstrapfx/bootstrapfx.css"); myStage.setMinWidth(900); myStage.setMinHeight(450); myStage.setTitle("Image Cipher"); myStage.setScene(scene); myStage.show(); logger.info("Showing MainWindow"); }); }
Example 7
Source Project: HealthPlus Source File: AddNewDrugController.java License: Apache License 2.0 | 6 votes |
public void showSuccessIndicator() { Stage stage= new Stage(); SuccessIndicatorController success = new SuccessIndicatorController(); Scene scene = new Scene(success); 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(); }
Example 8
Source Project: RadialFx Source File: RadialColorMenuDemo.java License: GNU Lesser General Public License v3.0 | 6 votes |
private void takeSnapshot(final Scene scene) { // Take snapshot of the scene final WritableImage writableImage = scene.snapshot(null); // Write snapshot to file system as a .png image final File outFile = new File("snapshot/radialmenu-snapshot-" + snapshotCounter + ".png"); outFile.getParentFile().mkdirs(); try { ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png", outFile); } catch (final IOException ex) { System.out.println(ex.getMessage()); } snapshotCounter++; }
Example 9
Source Project: uip-pc2 Source File: Movimientos.java License: MIT License | 6 votes |
public void salir(MouseEvent mouseEvent) { Stage stage = (Stage) salir.getScene().getWindow(); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Login.fxml")); Parent root = null; try { root = fxmlLoader.load(); } catch (Exception e) { Alert alerta = new Alert(Alert.AlertType.ERROR); alerta.setTitle("Error de Aplicación"); alerta.setContentText("Llama al lapecillo de sistemas."); alerta.showAndWait(); Platform.exit(); } FadeTransition ft = new FadeTransition(Duration.millis(1500), root); ft.setFromValue(0.0); ft.setToValue(1.0); ft.play(); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); }
Example 10
Source Project: HealthPlus Source File: LoginController.java License: Apache License 2.0 | 6 votes |
public void loadDoctor(String username) { Stage stage = new Stage(); DoctorController doctor = new DoctorController(username); doctor.fillAreaChart(); doctor.setAppointments(); doctor.loadProfileData(); doctor.MakeAvailabilityTable(); doctor.loadDrugList(); doctor.loadTestList(); doctor.setPaceholders(); doctor.addFocusListener(); doctor.loadNameList(); stage.setScene(new Scene(doctor)); 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); stage.show(); }
Example 11
Source Project: NSMenuFX Source File: RenameMenuItem.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void start(Stage primaryStage) throws Exception { StackPane root = new StackPane(); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.requestFocus(); primaryStage.show(); // Get the toolkit MenuToolkit tk = MenuToolkit.toolkit(); // Create the default Application menu Menu defaultApplicationMenu = tk.createDefaultApplicationMenu("test"); // Update the existing Application menu tk.setApplicationMenu(defaultApplicationMenu); // Since we now have a reference to the menu, we can rename items defaultApplicationMenu.getItems().get(1).setText("Hide all the otters"); }
Example 12
Source Project: JavaExercises Source File: HelloWorld.java License: GNU General Public License v2.0 | 6 votes |
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Hello World!"); 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!"); } }); StackPane root = new StackPane(); root.getChildren().add(btn); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show(); }
Example 13
Source Project: SmartCity-ParkingManagement Source File: MessageBox.java License: Apache License 2.0 | 6 votes |
public void display(final String title, final String message) { window = new Stage(); window.initModality(Modality.APPLICATION_MODAL); window.setTitle(title); window.setMinWidth(250); window.setMinHeight(100); window.getIcons().add(new Image(getClass().getResourceAsStream("Smart_parking_icon.png"))); final Label label = new Label(); label.setText(message); final VBox layout = new VBox(); layout.getChildren().addAll(label); layout.setAlignment(Pos.CENTER); final Scene scene = new Scene(layout); scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm()); window.setScene(scene); window.showAndWait(); }
Example 14
Source Project: javafx-gradle-plugin Source File: Main.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void start(Stage primaryStage) { StackPane root = new StackPane(new Label("Hello World!")); Scene scene = new Scene(root, 800, 600); primaryStage.setScene(scene); primaryStage.show(); new Thread(() -> { try { Thread.sleep(500); } catch (InterruptedException e) { throw new RuntimeException("Should not happen!"); } System.exit(0); }).start(); }
Example 15
Source Project: dctb-utfpr-2018-1 Source File: GUIController.java License: Apache License 2.0 | 6 votes |
public void startApp(Stage stage) { mainStage = stage; modalStage = new Stage(); modalStage.initOwner(mainStage); modalStage.initModality(Modality.APPLICATION_MODAL); mainStage.setMinWidth(1280); mainStage.setMinHeight(720); try { indexParent = FXMLLoader.load(getClass().getResource("register/CustomerRegister.fxml")); } catch (IOException ex) { Logger.getLogger(GUIController.class.getName()).log(Level.SEVERE, null, ex); } nowScene = new Scene(indexParent); executionStack.push(nowScene); mainStage.setScene(nowScene); //mainStage.show(); showCustomerRegister(false); }
Example 16
Source Project: markdown-writer-fx Source File: Utils.java License: BSD 2-Clause "Simplified" License | 6 votes |
public static void fixSpaceAfterDeadKey(Scene scene) { scene.addEventFilter( KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() { private String lastCharacter; @Override public void handle(KeyEvent e) { String character = e.getCharacter(); if(" ".equals(character) && ("\u00B4".equals(lastCharacter) || // Acute accent "`".equals(lastCharacter) || // Grave accent "^".equals(lastCharacter))) // Circumflex accent { // avoid that the space character is inserted e.consume(); } lastCharacter = character; } }); }
Example 17
Source Project: tornadofx-controls Source File: NaviSelectDemo.java License: Apache License 2.0 | 6 votes |
/** * Select value example. Implement whatever technique you want to change value of the NaviSelect */ private void selectEmail(NaviSelect<Email> navi) { Stage dialog = new Stage(StageStyle.UTILITY); dialog.setTitle("Choose person"); ListView<Email> listview = new ListView<>(FXCollections.observableArrayList( new Email("[email protected]", "John Doe"), new Email("[email protected]", "Jane Doe"), new Email("[email protected]", "Some Dude") )); listview.setOnMouseClicked(event -> { Email item = listview.getSelectionModel().getSelectedItem(); if (item != null) { navi.setValue(item); dialog.close(); } }); dialog.setScene(new Scene(listview)); dialog.setWidth(navi.getWidth()); dialog.initModality(Modality.APPLICATION_MODAL); dialog.setHeight(100); dialog.showAndWait(); }
Example 18
Source Project: gef Source File: SWT2FXGestureConversionDemo.java License: Eclipse Public License 2.0 | 6 votes |
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); shell.setText("SWT to FX Gesture Conversion Demo"); FXCanvasEx canvas = new FXCanvasEx(shell, SWT.NONE); Scene scene = createScene(); canvas.setScene(scene); shell.open(); shell.pack(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
Example 19
Source Project: gef Source File: SpringLayoutProgressExample.java License: Eclipse Public License 2.0 | 5 votes |
@Override protected Scene createScene(IViewer viewer) { Scene scene = super.createScene(viewer); Group overlay = ((InfiniteCanvasViewer) viewer).getCanvas() .getOverlayGroup(); toggleLayoutButton = new ToggleButton("step"); layoutAlgorithm = new SpringLayoutAlgorithm(); layoutAlgorithm.setRandom(true); ZestProperties.setLayoutAlgorithm(graph, layoutAlgorithm); overlay.getChildren().add(toggleLayoutButton); return scene; }
Example 20
Source Project: mars-sim Source File: JFXFlashTest.java License: GNU General Public License v3.0 | 5 votes |
@Override public void start(Stage primaryStage) throws Exception { final StackPane pane = new StackPane(); pane.setBackground(new Background(new BackgroundFill(Color.rgb(54, 54, 54), CornerRadii.EMPTY, Insets.EMPTY))); final Scene scene = new Scene(pane, 1024, 768); primaryStage.setScene(scene); primaryStage.show(); }
Example 21
Source Project: chart-fx Source File: BorderedTitledPaneTests.java License: Apache License 2.0 | 5 votes |
@Start public void start(Stage stage) { assertThrows(IllegalArgumentException.class, () -> new BorderedTitledPane("test", null)); testLabel = new Label("some irrelevant test label data"); assertDoesNotThrow(() -> new BorderedTitledPane("test", testLabel)); field = new BorderedTitledPane(testTitle, testLabel); stage.setScene(new Scene(field, 100, 100)); stage.show(); }
Example 22
Source Project: TelegramClone Source File: LogInController.java License: MIT License | 5 votes |
@FXML void signUp(ActionEvent event) { try { userName = userNameTextField.getText(); Parent root = FXMLLoader.load(getClass().getResource("../Views/home_view.fxml")); Main.stage.setScene(new Scene(root)); } catch (IOException e) { e.printStackTrace(); } }
Example 23
Source Project: WorkbenchFX Source File: DialogControlTest.java License: Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { this.stage = stage; MockitoAnnotations.initMocks(this); robot = new FxRobot(); blocking = new SimpleBooleanProperty(); mockDialog = mock(WorkbenchDialog.class); buttonTypes = FXCollections.observableArrayList(BUTTON_TYPE_1); when(mockDialog.getButtonTypes()).thenReturn(buttonTypes); when(mockDialog.getOnResult()).thenReturn(mockOnResult); when(mockDialog.blockingProperty()).thenReturn(blocking); mockBench = mock(Workbench.class); dialogControl = new MockDialogControl(); // simulate call of workbench to set itself in the dialogControl dialogControl.setWorkbench(mockBench); // simulate call of WorkbenchDialog to set itself in the dialogControl dialogControl.setDialog(mockDialog); // setup mocks for listeners dialogControl.setOnHidden(mockHiddenHandler); dialogControl.setOnShown(mockShownHandler); // setup second dialog control that isn't showing, to test behavior of skin listeners dialogControl2 = new MockDialogControl(); dialogControl2.setDialog(mockDialog); dialogControl2.setOnShown(mockShownHandler2); dialogControl2.setOnHidden(mockHiddenHandler2); Scene scene = new Scene(dialogControl, 100, 100); this.stage.setScene(scene); stage.show(); }
Example 24
Source Project: bisq Source File: BisqApp.java License: GNU Affero General Public License v3.0 | 5 votes |
private Scene createAndConfigScene(MainView mainView, Injector injector) { Rectangle maxWindowBounds = new Rectangle(); try { maxWindowBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); } catch (IllegalArgumentException e) { // Multi-screen environments may encounter IllegalArgumentException (Window must not be zero) // Just ignore the exception and continue, which means the window will use the minimum window size below // since we are unable to determine if we can use a larger size } Scene scene = new Scene(mainView.getRoot(), maxWindowBounds.width < INITIAL_WINDOW_WIDTH ? Math.max(maxWindowBounds.width, MIN_WINDOW_WIDTH) : INITIAL_WINDOW_WIDTH, maxWindowBounds.height < INITIAL_WINDOW_HEIGHT ? Math.max(maxWindowBounds.height, MIN_WINDOW_HEIGHT) : INITIAL_WINDOW_HEIGHT); addSceneKeyEventHandler(scene, injector); Preferences preferences = injector.getInstance(Preferences.class); preferences.getCssThemeProperty().addListener((ov) -> { CssTheme.loadSceneStyles(scene, preferences.getCssTheme()); }); CssTheme.loadSceneStyles(scene, preferences.getCssTheme()); return scene; }
Example 25
Source Project: Java-11-Cookbook-Second-Edition Source File: FxmlGuiDemo.java License: MIT License | 5 votes |
@Override public void start(Stage stage) throws IOException{ FXMLLoader loader = new FXMLLoader(); Pane pane = (Pane)loader.load(getClass() .getModule() .getResourceAsStream("com/packt/fxml_age_calc_gui.fxml") ); Scene scene = new Scene(pane,300, 250); stage.setTitle("Age calculator"); stage.setScene(scene); stage.show(); }
Example 26
Source Project: FXMaps Source File: RefImpl.java License: GNU Affero General Public License v3.0 | 5 votes |
@Override public void start(Stage primaryStage) throws Exception { this.primaryStage = primaryStage; createMapPane(); createToolBar(); Scene scene = new Scene(map.getNode(), Map.DEFAULT_WIDTH, Map.DEFAULT_HEIGHT); primaryStage.setScene(scene); primaryStage.show(); }
Example 27
Source Project: examples-javafx-repos1 Source File: HelpDialogController.java License: Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 28
Source Project: game-of-life-java Source File: GameOfLife.java License: MIT License | 5 votes |
@Override public void start(Stage primaryStage) throws Exception { Parent parent = FXMLLoader.load(getClass().getResource("gui.fxml")); primaryStage.setTitle("Conway's Game of Life"); primaryStage.setScene(new Scene(parent)); primaryStage.show(); }
Example 29
Source Project: samples Source File: HelloFX.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@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 30
Source Project: fx-progress-circle Source File: RingProgressIndicatorExample.java License: Apache License 2.0 | 5 votes |
@Override public void start(Stage primaryStage) { RingProgressIndicator indicator = new RingProgressIndicator(); Slider slider = new Slider(0, 100, 50); slider.valueProperty().addListener((o, oldVal, newVal) -> indicator.setProgress(newVal.intValue())); VBox main = new VBox(1, indicator, slider); indicator.setProgress(Double.valueOf(slider.getValue()).intValue()); Scene scene = new Scene(main); primaryStage.setScene(scene); primaryStage.setTitle("Test ring progress"); primaryStage.show(); }