javafx.scene.Parent Java Examples

The following examples show how to use javafx.scene.Parent. 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: CreateAndSaveKMLFileSample.java    From arcgis-runtime-samples-java with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {

  // set up the scene
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/create_and_save_kml_file/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set title, size and add scene to stage
  stage.setTitle("Create and Save KML File");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example #2
Source File: Navigator.java    From Flowless with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void layoutChildren() {
    // invalidate breadth for each cell that has dirty layout
    int n = cells.getMemoizedCount();
    for(int i = 0; i < n; ++i) {
        int j = cells.indexOfMemoizedItem(i);
        Node node = cells.get(j).getNode();
        if(node instanceof Parent && ((Parent) node).isNeedsLayout()) {
            sizeTracker.forgetSizeOf(j);
        }
    }

    if(!cells.isEmpty()) {
        targetPosition.clamp(cells.size())
                .accept(this);
    }
    currentPosition = getCurrentPosition();
    targetPosition = currentPosition;
}
 
Example #3
Source File: SingleImageCheck.java    From FakeImageDetection with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/resources/fxml/singleimage.fxml"));

    Scene scene = new Scene(root);

    stage.resizableProperty().setValue(false);
    stage.setTitle("Single Image Checker");
    stage.setScene(scene);
    stage.show();
    CommonUtil.attachIcon(stage);

    stage.setOnCloseRequest((WindowEvent event) -> {
        System.exit(0);
    });
}
 
Example #4
Source File: RadialMenu.java    From Enzo with Apache License 2.0 6 votes vote down vote up
public void show() {
    if (options.isButtonHideOnSelect() && mainMenuButton.getOpacity() > 0) {
        return;
    }

    if (options.isButtonHideOnSelect() || mainMenuButton.getOpacity() == 0) {
        mainMenuButton.setScaleX(1.0);
        mainMenuButton.setScaleY(1.0);
        cross.setRotate(0);
        mainMenuButton.setRotate(0);

        FadeTransition buttonFadeIn = new FadeTransition();
        buttonFadeIn.setNode(mainMenuButton);
        buttonFadeIn.setDuration(Duration.millis(200));
        buttonFadeIn.setToValue(options.getButtonAlpha());
        buttonFadeIn.play();
    }
    for (Parent node : items.keySet()) {
        node.setScaleX(1.0);
        node.setScaleY(1.0);
        node.setTranslateX(0);
        node.setTranslateY(0);
        node.setRotate(0);
    }
}
 
Example #5
Source File: UiUtils.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Fill a list of components.
 *
 * @param container the container
 * @param node      the node
 */
@FxThread
public static void fillComponents(@NotNull final Array<ScreenComponent> container, @NotNull final Node node) {

    if (node instanceof ScreenComponent) {
        container.add((ScreenComponent) node);
    }

    if (node instanceof SplitPane) {
        final ObservableList<Node> items = ((SplitPane) node).getItems();
        items.forEach(child -> fillComponents(container, child));
    } else if (node instanceof TabPane) {
        final ObservableList<Tab> tabs = ((TabPane) node).getTabs();
        tabs.forEach(tab -> fillComponents(container, tab.getContent()));
    }

    if (!(node instanceof Parent)) {
        return;
    }

    final ObservableList<Node> nodes = ((Parent) node).getChildrenUnmodifiable();
    nodes.forEach(child -> fillComponents(container, child));
}
 
Example #6
Source File: App.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void start(Stage stage) {
  try {
    // load splash
    Parent root = FXMLLoader.load(getClass().getResource("/jupiter/fxml/Splash.fxml"));
    // create scene and add styles
    Scene scene = new Scene(root, 500, 274);
    scene.getStylesheets().addAll(getClass().getResource("/jupiter/css/splash.css").toExternalForm());
    // set stage
    stage.setScene(scene);
    stage.setResizable(false);
    stage.initStyle(StageStyle.UNDECORATED);
    stage.getIcons().add(Icons.favicon());
    stage.toFront();
    stage.show();
  } catch (IOException e) {
    e.printStackTrace();
    Logger.error("could not load Jupiter GUI");
    Jupiter.exit(1);
  }
}
 
Example #7
Source File: MemoryPuzzleApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(600, 600);

    char c = 'A';
    List<Tile> tiles = new ArrayList<>();
    for (int i = 0; i < NUM_OF_PAIRS; i++) {
        tiles.add(new Tile(String.valueOf(c)));
        tiles.add(new Tile(String.valueOf(c)));
        c++;
    }

    Collections.shuffle(tiles);

    for (int i = 0; i < tiles.size(); i++) {
        Tile tile = tiles.get(i);
        tile.setTranslateX(50 * (i % NUM_PER_ROW));
        tile.setTranslateY(50 * (i / NUM_PER_ROW));
        root.getChildren().add(tile);
    }

    return root;
}
 
Example #8
Source File: DrawingApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(800, 600);

    Canvas canvas = new Canvas(800, 600);
    g = canvas.getGraphicsContext2D();

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            t += 0.017;
            draw();
        }
    };
    timer.start();

    root.getChildren().add(canvas);
    return root;
}
 
Example #9
Source File: CalibratePatchesBase.java    From testing-video with GNU General Public License v3.0 6 votes vote down vote up
protected Parent overlay(Args args) {
    Color fill = getTextFill(args);

    TextFlow topLeft = text(fill, getTopLeftText(args), LEFT);
    TextFlow topCenter = text(fill, getTopCenterText(args), CENTER);
    TextFlow topRight = text(fill, getTopRightText(args), RIGHT);
    TextFlow bottomLeft = text(fill, getBottomLeftText(args), LEFT);
    TextFlow bottomCenter = text(fill, getBottomCenterText(args), CENTER);
    TextFlow bottomRight = text(fill, getBottomRightText(args), RIGHT);

    StackPane top = new StackPane(topLeft, topCenter, topRight);
    StackPane bottom = new StackPane(bottomLeft, bottomCenter, bottomRight);

    BorderPane.setMargin(top, new Insets(20));
    BorderPane.setMargin(bottom, new Insets(20));

    BorderPane layout = new BorderPane();
    layout.setBackground(EMPTY);
    layout.setTop(top);
    layout.setBottom(bottom);

    return layout;
}
 
Example #10
Source File: MenuButtonApplication.java    From examples-javafx-repos1 with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {

    try {
        Parent p = FXMLLoader.load(getClass().getResource("/menubutton-fxml/CollegeSelection.fxml"));

        Scene scene = new Scene(p);

        primaryStage.setTitle("bekwam.com Menu Button Example");
        primaryStage.setScene( scene );
        primaryStage.show();

    } catch(IOException exc) {
        logger.error( "error loading fxml", exc );
        Alert alert = new Alert(Alert.AlertType.ERROR, "Error loading FXML");
        alert.showAndWait();
    }
}
 
Example #11
Source File: HiddenSidesPaneSkin.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private boolean hasShowingChild(Node n) {
    if (n == null) {
        return false;
    }
    if (n.isHover()) {
        lastHideBlockingNode = n;
        return true;
    }
    try {
        Method showingMethod = ClassDescriptions.getMethod(n.getClass(), "isShowing");
        if (showingMethod != null && (Boolean) showingMethod.invoke(n)) {
            lastHideBlockingNode = n;
            return true;
        }
    } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        // do nothing
    }
    if (n instanceof Parent) {
        return ((Parent) n).getChildrenUnmodifiable().stream().anyMatch(this::hasShowingChild);
    }
    return false;
}
 
Example #12
Source File: Main.java    From Everest with 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 #13
Source File: MapReferenceScaleSample.java    From arcgis-runtime-samples-java with Apache License 2.0 6 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {

  // set up the scene
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/map_reference_scale/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set up the stage
  stage.setTitle("Map Reference Scale Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example #14
Source File: AnimationApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(800, 600);

    NotificationPane pane = new NotificationPane(200, 600);
    pane.setTranslateX(800 - 200);

    Button btn = new Button("Animate");
    btn.setOnAction(e -> {
        pane.animate();
    });

    root.getChildren().addAll(btn, pane);

    return root;
}
 
Example #15
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 #16
Source File: MainController.java    From ApkCustomizationTool with Apache License 2.0 6 votes vote down vote up
public Stage getBuildStage() {
    if (buildStage == null) {
        try {
            Parent root = FXMLLoader.load(getClass().getResource("fxml/apk_build.fxml"));
            buildStage = new Stage();
            buildStage.setTitle(Main.TITLE);
            buildStage.setScene(new Scene(root));
            buildStage.initModality(Modality.NONE);
            buildStage.initStyle(StageStyle.UNIFIED);
            buildStage.setResizable(false);
            buildStage.initOwner(Main.stage);
            buildStage.setX(Main.stage.getX());
            buildStage.setY(Main.stage.getY() + Main.stage.getHeight());
            buildStage.setOnShown((event) -> {

            });
        } catch (Exception e) {
            e.printStackTrace();
            buildStage = null;
        }
    }
    return buildStage;
}
 
Example #17
Source File: FitToViewportAction.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns the {@link InfiniteCanvas} of the viewer where this action is
 * installed.
 *
 * @return The {@link InfiniteCanvas} of the viewer.
 */
protected InfiniteCanvas getInfiniteCanvas() {
	Parent canvas = getViewer().getCanvas();
	if (canvas instanceof InfiniteCanvas) {
		return (InfiniteCanvas) canvas;
	}
	return null;
}
 
Example #18
Source File: BackpressureDemo.java    From reactive-grpc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("Backpressure.fxml"));

    stage.setTitle("Reactive-gRPC Backpressure Demo");
    stage.setScene(new Scene(root, 800, 450));
    stage.show();
}
 
Example #19
Source File: MainWindow.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
private Scene getScene(Parent root) {
    Scene scene = new Scene(root);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    return scene;
}
 
Example #20
Source File: App.java    From SlidesRemote with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) {
    try {
        Parent root = FXMLLoader.load(getClass().getResource("/fxml/main.fxml"));
        stage.setScene(new Scene(root));
    } catch (IOException e) {
        e.printStackTrace();
    }

    stage.initStyle(StageStyle.UNDECORATED);
    App.stage = stage;
    stage.show();
}
 
Example #21
Source File: Main.java    From samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception{
    Parent root = FXMLLoader.load(getClass().getResource("hellofx.fxml"));
    primaryStage.setTitle("Hello World");
    primaryStage.setScene(new Scene(root, 400, 300));
    primaryStage.show();
}
 
Example #22
Source File: ActivityManager.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
/**
 * 启动一个Activity
 *
 * @param url   界面布局文件url
 * @param pos   界面位置
 */
public static void startActivity(URL url, Pos pos){
    try {
        Parent view = FXMLLoader.load(url);
        StackPane.setAlignment(view, pos);
        getRootView().getChildren().add(view);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #23
Source File: BisqApp.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showDebugWindow(Scene scene, Injector injector) {
    ViewLoader viewLoader = injector.getInstance(ViewLoader.class);
    View debugView = viewLoader.load(DebugView.class);
    Parent parent = (Parent) debugView.getRoot();
    Stage stage = new Stage();
    stage.setScene(new Scene(parent));
    stage.setTitle("Debug window"); // Don't translate, just for dev
    stage.initModality(Modality.NONE);
    stage.initStyle(StageStyle.UTILITY);
    stage.initOwner(scene.getWindow());
    stage.setX(this.stage.getX() + this.stage.getWidth() + 10);
    stage.setY(this.stage.getY());
    stage.show();
}
 
Example #24
Source File: Launcher.java    From JavaFX-Tutorial-Codes 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("/genuinecoder/main/main.fxml"));
    
    Scene scene = new Scene(root);
    
    stage.setScene(scene);
    stage.setTitle("Genuine Coder");
    stage.show();
}
 
Example #25
Source File: PokemonHomeController.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
@FXML
private void addPokemonAction() throws IOException {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getClassLoader().getResource("pokemonregister/View/PokemonDisplay.fxml"));
    Parent root = loader.load();
    
    PokemonDisplayController displayController = loader.getController();
    displayController.setScreenData(stage, DisplayMode.CREATE_POKEMON);
    
    Scene scene = new Scene(root);
    stage.setScene(scene);
}
 
Example #26
Source File: WindowsFx.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public void restoreWindow(FxWindow w)
{
	String windowPrefix = lookupWindowPrefix(w);
	
	LocalSettings settings = LocalSettings.find(w);
	if(settings != null)
	{
		String k = windowPrefix + FxSchema.SFX_SETTINGS;
		settings.loadValues(k);
	}
	FxSchema.restoreWindow(windowPrefix, w);
	
	Parent p = w.getScene().getRoot();
	FxSchema.restoreNode(windowPrefix, p, p);
}
 
Example #27
Source File: CodeGeneratorJFX.java    From Entitas-Java with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("EntitasGenerator.fxml"));
    Parent root = loader.load();
    primaryStage.setTitle("CodeGenerator");
    primaryStage.setScene(new Scene(root, 560, 575));
    primaryStage.setResizable(false);
    primaryStage.show();

    stage = primaryStage;

}
 
Example #28
Source File: TerrainExaggerationSample.java    From arcgis-runtime-samples-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
  // set up the scene
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/terrain_exaggeration/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set up the stage
  stage.setTitle("Terrain Exaggeration Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example #29
Source File: Main.java    From scan with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("靓号助手");
    Parent root = FXMLLoader.load(getClass().getResource("/app.fxml"));
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/scan.ico")));
    primaryStage.show();
}
 
Example #30
Source File: ZoomScaleContributionItem.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void unregister() {
	if (zoomListener == null) {
		throw new IllegalStateException(
				"Zoom listener not yet registered.");
	}
	Parent canvas = getViewer().getCanvas();
	if (canvas instanceof InfiniteCanvas) {
		((InfiniteCanvas) canvas).getContentTransform().mxxProperty()
				.removeListener(zoomListener);
		zoomListener = null;
	}
}