Example usage for javafx.scene.layout VBox getChildren

List of usage examples for javafx.scene.layout VBox getChildren

Introduction

In this page you can find the example usage for javafx.scene.layout VBox getChildren.

Prototype

@Override
public ObservableList<Node> getChildren() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Button Sample");
    stage.setWidth(300);//from  w  w w  .  ja  v  a 2 s. c om
    stage.setHeight(190);

    VBox vbox = new VBox();
    vbox.setLayoutX(20);
    vbox.setLayoutY(20);

    Image image = new Image(getClass().getResourceAsStream("a.png"));
    Button button1 = new Button("Accept", new ImageView(image));
    button1.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            System.out.println("Accepted");
        }
    });

    vbox.getChildren().add(button1);
    vbox.setSpacing(10);
    ((Group) scene.getRoot()).getChildren().add(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);//from w  w  w  . j  a va  2 s  . c o m
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem<String> depNode = new TreeItem<>(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }

    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<>(rootNode);
    treeView.setEditable(true);
    treeView.setCellFactory((TreeView<String> p) -> new TextFieldTreeCellImpl());

    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    rootNode.setExpanded(true);/*from w w  w  .  j  a v  a  2s  .  co  m*/
    for (Employee employee : employees) {
        TreeItem<String> empLeaf = new TreeItem<>(employee.getName());
        boolean found = false;
        for (TreeItem<String> depNode : rootNode.getChildren()) {
            if (depNode.getValue().contentEquals(employee.getDepartment())) {
                depNode.getChildren().add(empLeaf);
                found = true;
                break;
            }
        }
        if (!found) {
            TreeItem depNode = new TreeItem(employee.getDepartment());
            rootNode.getChildren().add(depNode);
            depNode.getChildren().add(empLeaf);
        }
    }

    stage.setTitle("Tree View Sample");
    VBox box = new VBox();
    final Scene scene = new Scene(box, 400, 300);
    scene.setFill(Color.LIGHTGRAY);

    TreeView<String> treeView = new TreeView<>(rootNode);
    treeView.setEditable(true);
    treeView.setCellFactory((TreeView<String> p) -> new TextFieldTreeCellImpl());

    box.getChildren().add(treeView);
    stage.setScene(scene);
    stage.show();
}

From source file:investor.views.CompaniesView.java

public void InitView() {
    selectedRange = DataRange.THREEMONTH;
    selectedChart = "line";
    pane = new VBox();
    lineChart = LinearChartManager.linear();
    lineChart.setTitle("");

    table = new TableView();

    try {//  ww w . jav  a 2s .c o  m
        table.getItems().addAll(NetworkManager.show(DataType.SPOL));
    } catch (Exception e) {
        System.out.println("Something went wrong when populating market indicisies view");
    }

    table.getColumns().addAll(initColumns());

    table.setRowFactory(tv -> {
        TableRow<Index> row = new TableRow<Index>();
        row.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && (!row.isEmpty())) {
                Index rowData = row.getItem();
                selectedIndex = rowData;
                //System.out.println(rowData);
                try {
                    lastData = NetworkManager.showMore(rowData.getSymbol(), selectedRange);
                    System.out.println(lastData.length);

                    if (selectedChart.equals("line")) {
                        lineChart.getData().clear();
                        lineChart.setTitle(rowData.getName());
                        LinearChartManager.addSeries(lineChart, lastData, selectedRange);
                        if (pointerType != null && pointerType != "hide") {
                            OnPointerChange();
                        }
                    } else {
                        CandleChart.generateData(lastData);
                        candleChart = new CandleChart();
                        CandleChart.CandleStickChart chart = candleChart.createChart();
                        chart.setTitle(rowData.getName());
                        pane.getStylesheets().add("resources/css/CandleStickChart.css");
                        borderPane.setCenter(chart);
                    }
                } catch (Exception ex) {
                    System.out.println("Error while downloading indicise " + ex.toString());
                }
            }
        });
        return row;
    });

    //table.setItems(initRows());
    table.setEditable(false);

    VBox vBox = (VBox) pane;

    borderPane = new BorderPane();
    borderPane.setCenter(lineChart);
    borderPane.setRight(addMenuButtons());

    vBox.getChildren().add(table);
    vBox.getChildren().add(borderPane);
}

From source file:org.pdfsam.split.SplitModule.java

@Override
protected Pane getInnerPanel() {
    VBox pane = new VBox();
    pane.setAlignment(Pos.TOP_CENTER);//w  ww . j a  v  a  2  s .  co m

    TitledPane prefixTitled = Views.titledPane(DefaultI18nContext.getInstance().i18n("File names settings"),
            prefix);
    prefix.addMenuItemFor(Prefix.CURRENTPAGE);
    prefix.addMenuItemFor(Prefix.FILENUMBER);

    pane.getChildren().addAll(selectionPane,
            Views.titledPane(DefaultI18nContext.getInstance().i18n("Split settings"), splitOptions),
            Views.titledPane(DefaultI18nContext.getInstance().i18n("Destination directory"), destinationPane),
            prefixTitled);
    return pane;
}

From source file:de.pixida.logtest.designer.MainWindow.java

private void initWindow() {
    final VBox top = new VBox();
    top.getChildren().addAll(this.createMenuBar());
    this.root.setTop(top);

    this.bindEditorDependentProperties();

    this.tabPane.getSelectionModel().selectedItemProperty().addListener((ov, oldTab, newTab) -> {
        this.bindEditorDependentProperties();
    });//from w  w  w. j av  a2s.com
    this.root.setCenter(this.tabPane);

    this.primaryStage.getIcons().add(Icons.getIconImage(APP_ICON));

    final Scene rootScene = new Scene(this.root, 800, 600);
    this.initDragAndDropForRootScene(rootScene);
    this.primaryStage.setScene(rootScene);
    this.primaryStage.setOnCloseRequest(event -> {
        if (!this.handleExitApplication()) {
            event.consume(); // Prevent window from closing
        }
    });
    this.primaryStage.show();

}

From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java

@Override
public Node getConfigFrame() {
    // TODO: Remove code redundancies; element creating methods have been created in class AutomatonEdge and should be centralized!
    final ConfigFrame cf = new ConfigFrame("State properties");

    final int nameInputLines = 1;
    final TextArea nameInput = new TextArea(this.name);
    nameInput.setPrefRowCount(nameInputLines);
    nameInput.setWrapText(true);/*w  w w  . ja  va2  s. c  om*/
    nameInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        this.setName(newValue);
        this.getGraph().handleChange();
    });
    cf.addOption("Name", nameInput);

    final int descriptionInputLines = 3;
    this.createTextAreaInput(descriptionInputLines, cf, "Description", this.getDescription(),
            newValue -> this.setDescription(newValue));

    final VBox typeAttributes = new VBox();
    final ToggleGroup flagToggleGroup = new ToggleGroup();
    typeAttributes.getChildren()
            .add(this.createRadioButtonForType(null, "None (intermediate node)", flagToggleGroup));
    typeAttributes.getChildren().add(this.createRadioButtonForType(Type.INITIAL, "Initial", flagToggleGroup));
    final RadioButton successOption = this.createRadioButtonForType(Type.SUCCESS, "Success", flagToggleGroup);
    typeAttributes.getChildren().add(successOption);
    typeAttributes.getChildren().add(this.createRadioButtonForType(Type.FAILURE, "Failure", flagToggleGroup));
    cf.addOption("Type", typeAttributes);

    final CheckBox waitCheckBox = new CheckBox("Active");
    waitCheckBox.setSelected(this.wait);
    waitCheckBox.setOnAction(event -> {
        this.setWait(waitCheckBox.isSelected());
        this.getGraph().handleChange();
    });
    cf.addOption("Wait", waitCheckBox);

    final int expressionInputLines = 1;
    final TextArea successCheckExpInput = new TextArea(this.successCheckExp);
    successCheckExpInput.setStyle("-fx-font-family: monospace");
    successCheckExpInput.setPrefRowCount(expressionInputLines);
    successCheckExpInput.setWrapText(false);
    successCheckExpInput.textProperty()
            .addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
                this.setSuccessCheckExp(newValue);
                this.getGraph().handleChange();
            });
    successCheckExpInput.disableProperty().bind(successOption.selectedProperty().not());
    cf.addOption("Script expression to verify if node is successful", successCheckExpInput);

    this.createEnterAndLeaveScriptConfig(cf);

    return cf;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    stage.setTitle("Menu Sample");
    Scene scene = new Scene(new VBox(), 400, 350);
    scene.setFill(Color.OLDLACE);

    name.setFont(new Font("Verdana Bold", 22));
    binName.setFont(new Font("Arial Italic", 10));
    pic.setFitHeight(150);// www. j  av a  2s .  c o m
    pic.setPreserveRatio(true);
    description.setWrapText(true);
    description.setTextAlignment(TextAlignment.JUSTIFY);

    shuffle();

    MenuBar menuBar = new MenuBar();

    // --- Graphical elements
    final VBox vbox = new VBox();
    vbox.setAlignment(Pos.CENTER);
    vbox.setSpacing(10);
    vbox.setPadding(new Insets(0, 10, 0, 10));
    vbox.getChildren().addAll(name, binName, pic, description);

    // --- Menu File
    Menu menuFile = new Menu("File");
    MenuItem add = new MenuItem("Shuffle", new ImageView(new Image("src/menusample/new.png")));
    add.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            shuffle();
            vbox.setVisible(true);
        }
    });

    MenuItem clear = new MenuItem("Clear");
    clear.setAccelerator(KeyCombination.keyCombination("Ctrl+X"));
    clear.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            vbox.setVisible(false);
        }
    });

    MenuItem exit = new MenuItem("Exit");
    exit.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            System.exit(0);
        }
    });

    menuFile.getItems().addAll(add, clear, new SeparatorMenuItem(), exit);

    // --- Menu Edit
    Menu menuEdit = new Menu("Edit");
    Menu menuEffect = new Menu("Picture Effect");

    final ToggleGroup groupEffect = new ToggleGroup();
    for (Entry effect : effects) {
        RadioMenuItem itemEffect = new RadioMenuItem((String) effect.getKey());
        itemEffect.setUserData(effect.getValue());
        itemEffect.setToggleGroup(groupEffect);
        menuEffect.getItems().add(itemEffect);
    }

    final MenuItem noEffects = new MenuItem("No Effects");
    noEffects.setDisable(true);
    noEffects.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            pic.setEffect(null);
            groupEffect.getSelectedToggle().setSelected(false);
            noEffects.setDisable(true);
        }
    });

    groupEffect.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue ov, Toggle old_toggle, Toggle new_toggle) {
            if (groupEffect.getSelectedToggle() != null) {
                Effect effect = (Effect) groupEffect.getSelectedToggle().getUserData();
                pic.setEffect(effect);
                noEffects.setDisable(false);
            } else {
                noEffects.setDisable(true);
            }
        }
    });

    menuEdit.getItems().addAll(menuEffect, noEffects);

    // --- Menu View
    Menu menuView = new Menu("View");
    CheckMenuItem titleView = createMenuItem("Title", name);
    CheckMenuItem binNameView = createMenuItem("Binomial name", binName);
    CheckMenuItem picView = createMenuItem("Picture", pic);
    CheckMenuItem descriptionView = createMenuItem("Decsription", description);

    menuView.getItems().addAll(titleView, binNameView, picView, descriptionView);
    menuBar.getMenus().addAll(menuFile, menuEdit, menuView);

    // --- Context Menu
    final ContextMenu cm = new ContextMenu();
    MenuItem cmItem1 = new MenuItem("Copy Image");
    cmItem1.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent content = new ClipboardContent();
            content.putImage(pic.getImage());
            clipboard.setContent(content);
        }
    });

    cm.getItems().add(cmItem1);
    pic.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent e) {
            if (e.getButton() == MouseButton.SECONDARY)
                cm.show(pic, e.getScreenX(), e.getScreenY());
        }
    });

    ((VBox) scene.getRoot()).getChildren().addAll(menuBar, vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

private VBox addVBox() {

    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10)); // Set all sides to 10
    vbox.setSpacing(8); // Gap between nodes

    Text title = new Text("Data");
    title.setFont(Font.font("Arial", FontWeight.BOLD, 14));
    vbox.getChildren().add(title);

    Hyperlink options[] = new Hyperlink[] { new Hyperlink("Sales"), new Hyperlink("Marketing"),
            new Hyperlink("Distribution"), new Hyperlink("Costs") };

    for (int i = 0; i < 4; i++) {
        // Add offset to left side to indent from title
        VBox.setMargin(options[i], new Insets(0, 0, 0, 8));
        vbox.getChildren().add(options[i]);
    }//from   w ww.ja v  a 2  s  .co m

    return vbox;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);/*w  w w  .  ja  v  a2s.  c o m*/

    VBox vb = new VBox();

    Rectangle rect = new Rectangle(100, 40, 100, 100);
    rect.setArcHeight(50);
    rect.setArcWidth(50);
    rect.setFill(Color.VIOLET);

    RotateTransition rt = new RotateTransition(Duration.millis(3000), rect);
    rt.setByAngle(180);
    rt.setAutoReverse(true);
    SequentialTransition seqTransition = new SequentialTransition(new PauseTransition(Duration.millis(1000)), // wait a second
            rt);
    seqTransition.play();

    vb.getChildren().add(rect);
    scene.setRoot(vb);
    stage.show();
}