Example usage for javafx.scene.layout FlowPane getChildren

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

Introduction

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

Prototype

@Override
public ObservableList<Node> getChildren() 

Source Link

Usage

From source file:com.bdb.weather.display.preferences.ColorPreferencePanel.java

public ColorPreferencePanel() {
    VBox vbox = new VBox();
    GridPane colorPanel = new GridPane();

    for (ColorPreferenceEntry entry : entries2) {
        ColorPicker colorPicker = new ColorPicker(preferences.getColorPref(entry.preferenceName));
        entry.button = colorPicker;/*from  w ww .j a v a2s . c o  m*/
        colorPanel.add(new Label(entry.preferenceName), 0, entry.row);
        colorPanel.add(colorPicker, 1, entry.row);
    }

    GridPane plotColorPanel = new GridPane();

    int gridx = 0;
    int gridy = 0;

    //
    // Layout the column headers
    //
    for (int i = 0; i < COLOR_COL_HEADERS.length; i++) {
        gridx = i;
        plotColorPanel.add(new Label(COLOR_COL_HEADERS[i]), gridx, gridy);
    }

    //
    // Layout the row leaders
    //
    //c.anchor = GridBagConstraints.EAST;
    for (String header : COLOR_ROW_HEADERS) {
        gridx = 0;
        gridy++;
        plotColorPanel.add(new Label(header), gridx, gridy);

        gridx = 5;

        Set<String> names = ColorSchemeCollection.getColorSchemeNames();
        ComboBox<String> scheme = new ComboBox<>();
        scheme.getItems().addAll(names);
        scheme.setUserData(gridy);
        plotColorPanel.add(scheme, gridx, gridy);
        scheme.setOnAction((ActionEvent e) -> {
            ComboBox<String> cb = (ComboBox<String>) e.getSource();
            applyColorScheme((Integer) cb.getUserData(), cb.getSelectionModel().getSelectedItem());
        });
        gridx = 6;
        CheckBox showSeries = new CheckBox();
        showSeries.setUserData(gridy);
        plotColorPanel.add(showSeries, gridx, gridy);
        showSeries.setOnAction((ActionEvent e) -> {
            CheckBox cb = (CheckBox) e.getSource();
            int row = (Integer) cb.getUserData();
            for (ColorPreferenceEntry entry : entries) {
                if (entry.row == row) {
                    addRemoveSeries(entry.preferenceName, cb.isSelected());
                }
            }
            createSeriesData();
            configureRenderer();
        });
    }

    //c.anchor = GridBagConstraints.CENTER;
    for (ColorPreferenceEntry entry : entries) {
        gridx = entry.column;
        gridy = entry.row;
        ColorPicker button = new ColorPicker();
        button.setValue(preferences.getColorPref(entry.preferenceName));
        //button.setPrefSize(10, 10);
        button.setUserData(entry);
        plotColorPanel.add(button, gridx, gridy);
        entry.button = button;
    }

    JFreeChart chart = ChartFactory.createXYLineChart("Example", "X Axis", "Y Axis", dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(renderer);

    ChartViewer graphExamplePanel = new ChartViewer(chart);

    vbox.getChildren().addAll(colorPanel, plotColorPanel);
    setTop(vbox);
    setCenter(graphExamplePanel);
    FlowPane buttonPanel = new FlowPane();
    Button button = new Button("OK");
    button.setOnAction((ActionEvent e) -> {
        saveData();
    });
    buttonPanel.getChildren().add(button);
    setBottom(buttonPanel);
}

From source file:com.thomaskuenneth.tkmactuning.TKMacTuning.java

@Override
public void start(Stage primaryStage) {
    TabPane tabPane = new TabPane();
    tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
    // Found here: http://stackoverflow.com/a/17488304/5956451
    tabPane.getStyleClass().add("floating");

    // TODO: propper error handling
    JSONTokener t = new JSONTokener(getClass().getResourceAsStream("resources/plugins.json"));
    JSONArray a = new JSONArray(t);
    a.forEach((Object anObject) -> {
        JSONObject jsonObject = (JSONObject) anObject;
        addPlugin(tabPane, jsonObject.getString("class"), jsonObject.getString("pluginName"));
    });//from   w  w  w.  ja v  a 2 s.c  o  m

    FlowPane buttonsPane = new FlowPane(Orientation.HORIZONTAL);
    buttonsPane.setPadding(LayoutConstants.PADDING_1);
    buttonsPane.setHgap(LayoutConstants.HORIZONTAL_CONTROL_GAP);
    buttonsPane.setAlignment(Pos.BASELINE_LEFT);
    final Button buttonReread = new Button(getString("reread"));
    buttonReread.setOnAction(event -> {
        PluginManager.reread(this);
    });
    buttonsPane.getChildren().add(buttonReread);
    final Button buttonApply = new Button(getString("apply"));
    buttonApply.setOnAction(event -> {
        PluginManager.save(this);
    });
    buttonsPane.getChildren().add(buttonApply);

    statusbar = new StatusBar();
    BorderPane borderPane = new BorderPane(tabPane);
    borderPane.setTop(buttonsPane);
    borderPane.setBottom(statusbar);
    primaryStage.setScene(new Scene(borderPane, 800, 600));
    primaryStage.setTitle(getString("application_name"));

    ready();
    primaryStage.show();
}

From source file:ipat_fx.FXMLDocumentController.java

@FXML
public void resetScores() {

    HashMap<String, Hint> hintMap = controller.hints;
    TabPane tabpane = (TabPane) byProfilePane.getChildren().get(0);
    Tab tab = null;// w ww .ja va 2  s.  c om
    if (tabFlag.equalsIgnoreCase("byProfile")) {
        tab = tabpane.getTabs().get(0);
    } else if (tabFlag.equalsIgnoreCase("byImage")) {
        tab = tabpane.getTabs().get(0);
    } else {
        Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null,
                "Something wrong with tabFlag");
    }
    ScrollPane scrollPane = (ScrollPane) tab.getContent();
    FlowPane flowPane = (FlowPane) scrollPane.getContent();
    Iterator<Node> cellsIterator = flowPane.getChildren().iterator();
    while (cellsIterator.hasNext()) {
        GridPane cell = (GridPane) cellsIterator.next();
        Iterator<Node> cellIterator = cell.getChildren().iterator();
        while (cellIterator.hasNext()) {
            Node cellElement = cellIterator.next();
            if (cellElement instanceof Slider) {
                Set<String> keySet = hintMap.keySet();// get the hints one by one and apply to cell
                int keyCount = 0;
                for (String key : keySet) {
                    Hint h = hintMap.get(key);
                    Slider slider = ((Slider) cellElement);
                    String[] split = slider.getId().split("_");
                    if (split[0].equalsIgnoreCase(h.getHintName())) {
                        slider.setValue(Double.valueOf(h.getDefaultValue()));
                    }
                }
            }
            if (cellElement instanceof CheckBox) {
                ((CheckBox) cellElement).setSelected(false);
            }
        }
    }
}

From source file:ipat_fx.FXMLDocumentController.java

@FXML
public void nextGeneration() {

    //check if num of profiles is a valid input 
    int numOfProfiles = Integer.parseInt(noOfProfiles.getText());
    if (numOfProfiles > 8) {
        JOptionPane.showMessageDialog(null, "Please make the number of profiles smaller than 8.");
    } else {//from  ww w  . j  a v  a2 s . co  m
        HashMap<String, Object> scores = new HashMap<>();
        // TODO get the scores from the user input to then get the next gen

        ObservableList<Tab> tabs = null;

        if (tabFlag.equalsIgnoreCase("byImage")) {
            tabs = byImageTab.getTabs();
        } else if (tabFlag.equalsIgnoreCase("byProfile")) {
            tabs = byProfileTab.getTabs();
        } else {
            System.out.println("Something is wrong with tabFlag in FXML DOC CONT");
        }

        Iterator<Tab> profileTabIterator = tabs.iterator();
        while (profileTabIterator.hasNext()) {
            Tab profileTab = profileTabIterator.next();
            ScrollPane scrollPane = (ScrollPane) profileTab.getContent();
            FlowPane cells = (FlowPane) scrollPane.getContent();
            Iterator<Node> cellIterator = cells.getChildren().iterator();
            while (cellIterator.hasNext()) {
                GridPane cell = (GridPane) cellIterator.next();
                Iterator<Node> nodeIterator = cell.getChildren().iterator();
                while (nodeIterator.hasNext()) {
                    Node cellElement = nodeIterator.next();
                    if (cellElement instanceof Slider) {
                        scores.put(cellElement.getId(), String.valueOf(((Slider) cellElement).getValue()));
                    }
                    if (cellElement instanceof CheckBox) {
                        scores.put(cellElement.getId(), ((CheckBox) cellElement).isSelected());
                    }
                }
            }
        }

        HashMap<String, Object> display = controller.mainloop(scores, numOfProfiles);
        WebView previewView = (WebView) display.get("previewView");
        previewPane.getChildren().add(previewView);
        @SuppressWarnings("unchecked")
        HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display
                .get("results");

        if (tabFlag.equalsIgnoreCase("byImage")) {
            byImageTab = getByImage(map);
            byImagePane.setCenter(byImageTab);
        } else if (tabFlag.equalsIgnoreCase("byProfile")) {
            byProfileTab = getByProfile(map, numOfProfiles);
            byProfilePane.setCenter(byProfileTab);
        }

        tabPane.getSelectionModel().selectedIndexProperty()
                .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> {
                    if (newValue == Number.class.cast(1)) {
                        byImageTab = getByImage(map);
                        byImagePane.setCenter(byImageTab);
                    } else if (newValue == Number.class.cast(0)) {
                        byProfileTab = getByProfile(map, numOfProfiles);
                        byProfilePane.setCenter(byProfileTab);
                    } else {
                        System.out.println("Error this tab has not been created.");
                    }
                });
    }
}

From source file:Main.java

private FlowPane addFlowPane() {

    FlowPane flow = new FlowPane();
    flow.setPadding(new Insets(5, 0, 5, 0));
    flow.setVgap(4);// w ww.j  a v  a2  s  .  c o m
    flow.setHgap(4);
    flow.setPrefWrapLength(170); // preferred width allows for two columns
    flow.setStyle("-fx-background-color: DAE6F3;");

    ImageView pages[] = new ImageView[8];
    for (int i = 0; i < 8; i++) {
        pages[i] = new ImageView(
                new Image(Main.class.getResourceAsStream("graphics/chart_" + (i + 1) + ".png")));
        flow.getChildren().add(pages[i]);
    }

    return flow;
}

From source file:ipat_fx.FXMLDocumentController.java

public TabPane getByProfile(HashMap<String, ArrayList<GridPane>> map, int noOfProfiles) {

    TabPane tabpane = new TabPane();
    Tab tabForProfile;/*from   w  ww. ja  va 2  s . c o  m*/
    FlowPane paneForProfile;

    for (int i = 0; i < noOfProfiles; i++) {
        tabForProfile = new Tab();
        paneForProfile = new FlowPane();
        tabForProfile.setId("li_Profile_" + i);
        tabForProfile.setText("Profile " + i);
        int j = 0;
        for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext(); j++) {
            String nameOfArtefact = iterator.next();
            ArrayList<GridPane> cells = map.get(nameOfArtefact);
            paneForProfile.getChildren().add(cells.get(i));
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(paneForProfile);
        tabForProfile.setContent(scrollPane);
        tabpane.getTabs().add(tabForProfile);
    }
    return tabpane;
}

From source file:ipat_fx.FXMLDocumentController.java

public TabPane getByImage(HashMap<String, ArrayList<GridPane>> map) {

    TabPane tabpane = new TabPane();
    Tab tabForImage;/* ww w  . j  a va2 s  .co  m*/
    FlowPane paneForImage;

    Iterator<String> iterator = map.keySet().iterator();
    while (iterator.hasNext()) {
        tabForImage = new Tab();
        paneForImage = new FlowPane();
        String nameOfArtefact = iterator.next();
        tabForImage.setId("li_" + nameOfArtefact);
        tabForImage.setText(nameOfArtefact);
        ArrayList<GridPane> cells = map.get(nameOfArtefact);
        for (GridPane cell1 : cells) {
            GridPane cell = cell1;
            //paneForImage.add(cell, 0, i);
            paneForImage.getChildren().add(cell);
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(paneForImage);
        tabForImage.setContent(scrollPane);
        tabpane.getTabs().add(tabForImage);
    }
    return tabpane;
}

From source file:io.bitsquare.gui.components.paymentmethods.OKPayForm.java

private void addCurrenciesGrid(boolean isEditable) {
    Label label = addLabel(gridPane, ++gridRow, "Supported currencies:", 0);
    GridPane.setValignment(label, VPos.TOP);
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);//  w ww. jav  a 2s .c om
    flowPane.setHgap(10);

    if (isEditable)
        flowPane.setId("flow-pane-checkboxes-bg");
    else
        flowPane.setId("flow-pane-checkboxes-non-editable-bg");

    CurrencyUtil.getAllOKPayCurrencies().stream().forEach(e -> {
        CheckBox checkBox = new CheckBox(e.getCode());
        checkBox.setMouseTransparent(!isEditable);
        checkBox.setSelected(okPayAccount.getTradeCurrencies().contains(e));
        checkBox.setMinWidth(60);
        checkBox.setMaxWidth(checkBox.getMinWidth());
        checkBox.setTooltip(new Tooltip(e.getName()));
        checkBox.setOnAction(event -> {
            if (checkBox.isSelected())
                okPayAccount.addCurrency(e);
            else
                okPayAccount.removeCurrency(e);

            updateAllInputsValid();
        });
        flowPane.getChildren().add(checkBox);
    });

    GridPane.setRowIndex(flowPane, gridRow);
    GridPane.setColumnIndex(flowPane, 1);
    gridPane.getChildren().add(flowPane);
}

From source file:io.bitsquare.gui.components.paymentmethods.SepaForm.java

private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList,
        List<Country> dataProvider) {
    Label label = addLabel(gridPane, ++gridRow, title, 0);
    label.setWrapText(true);//from   w w  w  . j a va2  s . co m
    label.setMaxWidth(180);
    label.setTextAlignment(TextAlignment.RIGHT);
    GridPane.setHalignment(label, HPos.RIGHT);
    GridPane.setValignment(label, VPos.TOP);
    FlowPane flowPane = new FlowPane();
    flowPane.setPadding(new Insets(10, 10, 10, 10));
    flowPane.setVgap(10);
    flowPane.setHgap(10);
    flowPane.setMinHeight(55);

    if (isEditable)
        flowPane.setId("flow-pane-checkboxes-bg");
    else
        flowPane.setId("flow-pane-checkboxes-non-editable-bg");

    dataProvider.stream().forEach(country -> {
        final String countryCode = country.code;
        CheckBox checkBox = new CheckBox(countryCode);
        checkBox.setUserData(countryCode);
        checkBoxList.add(checkBox);
        checkBox.setMouseTransparent(!isEditable);
        checkBox.setMinWidth(45);
        checkBox.setMaxWidth(45);
        checkBox.setTooltip(new Tooltip(country.name));
        checkBox.setOnAction(event -> {
            if (checkBox.isSelected())
                sepaAccount.addAcceptedCountry(countryCode);
            else
                sepaAccount.removeAcceptedCountry(countryCode);

            updateAllInputsValid();
        });
        flowPane.getChildren().add(checkBox);
    });
    updateCountriesSelection(isEditable, checkBoxList);

    GridPane.setRowIndex(flowPane, gridRow);
    GridPane.setColumnIndex(flowPane, 1);
    gridPane.getChildren().add(flowPane);
}

From source file:com.bekwam.resignator.ResignatorAppMainViewController.java

@FXML
public void openJarsignerConfig() {

    clearValidationErrors();// w  ww.  ja  v  a2 s. c  o m

    if (StringUtils.isNotEmpty(activeConfiguration.getJDKHome())) {

        JarsignerConfigController jarsignerConfigView = jarsignerConfigControllerProvider.get();
        jarsignerConfigView.setParent(this);
        try {
            jarsignerConfigView.show();
        } catch (Exception exc) {
            String msg = "Error launching jarsigner config";
            logger.error(msg, exc);
            Alert alert = new Alert(Alert.AlertType.ERROR, msg);
            alert.showAndWait();
        }
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("[OPEN JARSIGNER CONFIG] JDK_HOME not set");
        }

        Alert alert = new Alert(Alert.AlertType.ERROR, "Set JDK_HOME in File > Settings");
        alert.setHeaderText("JDK_HOME not defined");

        FlowPane fp = new FlowPane();
        Label lbl = new Label("Set JDK_HOME in ");
        Hyperlink link = new Hyperlink("File > Settings");
        fp.getChildren().addAll(lbl, link);

        link.setOnAction((evt) -> {
            alert.close();
            openSettings();
        });

        alert.getDialogPane().contentProperty().set(fp);

        alert.showAndWait();
    }
}