javafx.scene.Scene Java Examples

The following examples show how to use javafx.scene.Scene. 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: Utils.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #2
Source File: WindowController.java    From Image-Cipher with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: MessageBox.java    From SmartCity-ParkingManagement with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: AddNewDrugController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: RadialColorMenuDemo.java    From RadialFx with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #6
Source File: HelloWorld.java    From JavaExercises with GNU General Public License v2.0 6 votes vote down vote up
@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 #7
Source File: Main.java    From javafx-gradle-plugin with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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 #8
Source File: Demo.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: GUIController.java    From dctb-utfpr-2018-1 with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: MultiSelectDemo.java    From tornadofx-controls with Apache License 2.0 6 votes vote down vote up
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 #11
Source File: NaviSelectDemo.java    From tornadofx-controls with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #12
Source File: Movimientos.java    From uip-pc2 with MIT License 6 votes vote down vote up
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 #13
Source File: Test.java    From medusademo with Apache License 2.0 6 votes vote down vote up
@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 #14
Source File: SWT2FXGestureConversionDemo.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
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 #15
Source File: DataSetMeasurementsTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: RenameMenuItem.java    From NSMenuFX with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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 #17
Source File: LoginController.java    From HealthPlus with Apache License 2.0 6 votes vote down vote up
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 #18
Source File: PCGenPreloader.java    From pcgen with 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 #19
Source File: PokemonDisplayController.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
@FXML
private void cancelAction() throws IOException {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getClassLoader().getResource("pokemonregister/View/PokemonHome.fxml"));
    Parent root = loader.load();

    PokemonHomeController homeController = (PokemonHomeController) loader.getController();
    homeController.setMainStage(stage);

    Scene scene = new Scene(root);
    stage.setScene(scene);
}
 
Example #20
Source File: StartProject.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("/sms/view/fxml/login.fxml"));
    primaryStage.setTitle("School Management System");
    primaryStage.setScene(new Scene(root));
    primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/sms/other/img/HikmaLogo.jpg")));
    primaryStage.show();
}
 
Example #21
Source File: Pokedex.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("view/Index.fxml"));
    
    Scene scene = new Scene(root);
    stage.setTitle("Pokedex");
    stage.setScene(scene);
    stage.show();
}
 
Example #22
Source File: Maus.java    From Maus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException, ClassNotFoundException {
    Maus.primaryStage = primaryStage;
    /* Ensure that the necessary files exist */
    new PseudoBase().createMausData();
    /* Load data from files - including client data, server settings, etc. */
    new PseudoBase().loadData();
    /* Set up primary view */
    getPrimaryStage().setTitle(MausSettings.CURRENT_VERSION);

    SwingUtilities.invokeLater(this::addAppToTray);
    Platform.setImplicitExit(false);
    Scene mainScene = new Scene(new MainView().getMainView(), 900, 500);
    mainScene.getStylesheets().add(getClass().getResource("/css/global.css").toExternalForm());
    getPrimaryStage().setScene(mainScene);
    getPrimaryStage().getIcons().add(new Image(getClass().getResourceAsStream("/Images/Icons/icon.png")));
    getPrimaryStage().setOnCloseRequest(event -> System.exit(0));

    /* Maus is running! */
    Logger.log(Level.INFO, "Maus is running.");
    getPrimaryStage().initStyle(StageStyle.UNDECORATED);

    /* Set user's IP as Server IP */
    URL whatismyip = new URL("http://checkip.amazonaws.com");
    BufferedReader in = new BufferedReader(new InputStreamReader(
            whatismyip.openStream()));

    String ip = in.readLine();
    MausSettings.CONNECTION_IP = ip;
    getPrimaryStage().show();

    /* Start the server to listen for client connections. */
    Runnable startServer = server;
    new Thread(startServer).start();
}
 
Example #23
Source File: ChooseParkingSlotController.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
@FXML
public void showDistanceChartButtonClicked(ActionEvent event) throws Exception{
	
	 Stage s = new Stage();
        //Fill stage with content
		s.setTitle("Price - Distance graph");
        final NumberAxis xAxis = new NumberAxis(), yAxis = new NumberAxis();
        xAxis.setLabel("Distance");
        yAxis.setLabel("Price");

        //creating the chart
        final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis);
                
        lineChart.setTitle("Price - Distance");
        
        //defining a series
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Price - Distance");
        
        //get data to present
        Graph g = new Graph();
        Map<Double, Double> data = g.CreatePriceDistanceData(getSelectedDestination());

        //populating the series with data
        for (Map.Entry<Double, Double> entry : data.entrySet()){
        	Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info("distance: "+ entry.getKey() + " price: " + entry.getValue());
        	series.getData().add(new Data<Number, Number>(entry.getKey(), entry.getValue()));
        }
	        
        Scene scene  = new Scene(lineChart,800,600);
        lineChart.getData().addAll(series);
       
        s.setScene(scene);
        s.show();
}
 
Example #24
Source File: MinesweeperApp.java    From FXTutorials with 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 #25
Source File: ToolBarDemo.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    JFXToolbar jfxToolbar = new JFXToolbar();
    jfxToolbar.setLeftItems(new Label("Left"));
    jfxToolbar.setRightItems(new Label("Right"));

    StackPane main = new StackPane();
    main.getChildren().add(jfxToolbar);

    Scene scene = new Scene(main, 600, 400);
    scene.getStylesheets().add(ToolBarDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #26
Source File: FlipClock.java    From Enzo with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    HBox dayBox = new HBox();
    dayBox.setSpacing(0);
    dayBox.getChildren().addAll(dayLeft, dayMid, dayRight);
    dayBox.setLayoutX(12);
    dayBox.setLayoutY(76);

    HBox dateBox = new HBox();
    dateBox.setSpacing(0);
    dateBox.getChildren().addAll(dateLeft, dateRight);
    dateBox.setLayoutX(495);
    dateBox.setLayoutY(76);

    HBox monthBox = new HBox();
    monthBox.setSpacing(0);
    monthBox.getChildren().addAll(monthLeft, monthMid, monthRight);
    monthBox.setLayoutX(833);
    monthBox.setLayoutY(76);

    HBox clockBox = new HBox();
    clockBox.setSpacing(0);
    HBox.setMargin(hourRight, new Insets(0, 40, 0, 0));
    HBox.setMargin(minRight, new Insets(0, 40, 0, 0));
    clockBox.getChildren().addAll(hourLeft, hourRight, minLeft, minRight, secLeft, secRight);
    clockBox.setLayoutY(375);

    Pane pane = new Pane(dayBox, dateBox, monthBox, clockBox);
    pane.setPadding(new Insets(10, 10, 10, 10));

    Scene scene = new Scene(pane, 1280, 800, new LinearGradient(0, 0, 0, 800, false, CycleMethod.NO_CYCLE,
                                                                new Stop(0.0, Color.rgb(28, 27, 22)),
                                                                new Stop(0.25, Color.rgb(38, 37, 32)),
                                                                new Stop(1.0, Color.rgb(28, 27, 22))));
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example #27
Source File: Main.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    Config.initialize();
    Group root = new Group();
    mainFrame = new MainFrame(root);
    stage.setTitle("Brick Breaker");
    stage.setResizable(false);
    stage.setWidth(Config.SCREEN_WIDTH + 2*Config.WINDOW_BORDER);
    stage.setHeight(Config.SCREEN_HEIGHT+ 2*Config.WINDOW_BORDER + Config.TITLE_BAR_HEIGHT);
    Scene scene = new Scene(root);
    scene.setFill(Color.BLACK);
    stage.setScene(scene);
    mainFrame.changeState(MainFrame.SPLASH);
    stage.show();
}
 
Example #28
Source File: HelloFX.java    From samples with 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 #29
Source File: Mokka7App.java    From mokka7 with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {

    String version = Mokka7App.class.getPackage().getImplementationVersion();

    stage.setTitle(String.format("Mokka7 client v.%s", version != null ? version : "DEV"));
    stage.setResizable(true);

    Injector.setLogger((t) -> logger.trace(t));

    Injector.setModelOrService(MonitoredS7Client.class, new MonitoredS7Client());

    SessionManager session = Injector.instantiateModelOrService(SessionManager.class);
    session.setSession(getClass().getName().toLowerCase());
    session.loadSession();

    session.bind(sceneWidthProperty, "scene.width");
    session.bind(sceneHeightProperty, "scene.height");

    MainView main = new MainView();

    final Scene scene = new Scene(main.getView(), sceneWidthProperty.get(), sceneHeightProperty.get());
    stage.setOnCloseRequest((e) -> {
        sceneWidthProperty.set(scene.getWidth());
        sceneHeightProperty.set(scene.getHeight());
        Injector.forgetAll();
        System.exit(0);
    });
    stage.setScene(scene);
    Image icon16 = new Image(getClass().getResourceAsStream("icon-16x16.png"));
    Image icon32 = new Image(getClass().getResourceAsStream("icon-32x32.png"));
    Image icon48 = new Image(getClass().getResourceAsStream("icon-48x48.png"));

    stage.getIcons().addAll(icon16, icon32, icon48);

    stage.show();

}
 
Example #30
Source File: ScrollGesture.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void hookScene(Scene scene, IViewer viewer) {
	// register scroll filter
	EventHandler<ScrollEvent> scrollFilter = createScrollFilter(viewer);
	scrollFilters.put(viewer, scrollFilter);
	scrollFilterScenes.put(scrollFilter, scene);
	scene.addEventFilter(ScrollEvent.SCROLL, scrollFilter);
}