类javafx.scene.Scene源码实例Demo

下面列出了怎么用javafx.scene.Scene的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pcgen   文件: PCGenPreloader.java
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();
	});
}
 
源代码2 项目: chart-fx   文件: DataSetMeasurementsTests.java
@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();
}
 
源代码3 项目: medusademo   文件: Test.java
@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");

}
 
源代码4 项目: tornadofx-controls   文件: MultiSelectDemo.java
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();
}
 
源代码5 项目: Enzo   文件: Demo.java
@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();
}
 
源代码6 项目: Image-Cipher   文件: WindowController.java
@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");
  });
}
 
源代码7 项目: HealthPlus   文件: AddNewDrugController.java
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();
}
 
源代码8 项目: RadialFx   文件: RadialColorMenuDemo.java
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++;
   }
 
源代码9 项目: uip-pc2   文件: Movimientos.java
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();
}
 
源代码10 项目: HealthPlus   文件: LoginController.java
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();
}
 
源代码11 项目: NSMenuFX   文件: RenameMenuItem.java
@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");
}
 
源代码12 项目: JavaExercises   文件: HelloWorld.java
@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();
}
 
源代码13 项目: SmartCity-ParkingManagement   文件: MessageBox.java
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();

}
 
源代码14 项目: javafx-gradle-plugin   文件: Main.java
@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();
}
 
源代码15 项目: dctb-utfpr-2018-1   文件: GUIController.java
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);
}
 
源代码16 项目: markdown-writer-fx   文件: Utils.java
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;
		}
	});
}
 
源代码17 项目: tornadofx-controls   文件: NaviSelectDemo.java
/**
 * 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();
}
 
源代码18 项目: gef   文件: SWT2FXGestureConversionDemo.java
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();
}
 
源代码19 项目: gef   文件: SpringLayoutProgressExample.java
@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;
}
 
源代码20 项目: mars-sim   文件: JFXFlashTest.java
@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();
}
 
源代码21 项目: chart-fx   文件: BorderedTitledPaneTests.java
@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();
}
 
源代码22 项目: TelegramClone   文件: LogInController.java
@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();
    }
}
 
源代码23 项目: WorkbenchFX   文件: DialogControlTest.java
@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();
}
 
源代码24 项目: bisq   文件: BisqApp.java
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;
}
 
@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();
}
 
源代码26 项目: FXMaps   文件: RefImpl.java
@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();
}
 
@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();
        }
    }
}
 
源代码28 项目: game-of-life-java   文件: GameOfLife.java
@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();
}
 
源代码29 项目: samples   文件: HelloFX.java
@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();
}
 
@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();

}
 
 类所在包
 同包方法