Example usage for javafx.scene.layout HBox getChildren

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

Introduction

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

Prototype

@Override
public ObservableList<Node> getChildren() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    // 5 pixels space between child nodes
    HBox hbox = new HBox(5);
    // 1 pixel padding between child nodes only
    hbox.setPadding(new Insets(1));
    Rectangle r1 = new Rectangle(10, 10);
    Rectangle r2 = new Rectangle(20, 100);
    Rectangle r3 = new Rectangle(50, 20);
    Rectangle r4 = new Rectangle(20, 50);

    HBox.setMargin(r1, new Insets(2, 2, 2, 2));

    hbox.getChildren().addAll(r1, r2, r3, r4);
    root.getChildren().add(hbox);//  ww w  .j  a  v a 2  s.  c  o  m

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

From source file:com.bdb.weather.display.current.Thermometer.java

/**
 * Constructor.//from w w w. j  a va  2  s  .c om
 * 
 * @param title The title to display in the containing panel
 * @param min The minimum value for the thermometer scale
 * @param max The maximum value for the thermometer scale
 */
public Thermometer(String title, Temperature min, Temperature max) {
    this.setPrefSize(150.0, 200.0);
    minValue = min;
    maxValue = max;
    unitProperty.setValue(Temperature.getDefaultUnit());
    setUnits(unitProperty.getValue());
    ChartViewer chartViewer = createChartElements();
    this.setCenter(chartViewer);
    HBox p = new HBox();
    p.setAlignment(Pos.CENTER);
    Label label = new Label("High: ");
    label.setStyle("-fx-font-weight: bold");
    p.getChildren().addAll(label, highLabel);
    this.setTop(p);
    p = new HBox();
    p.setAlignment(Pos.CENTER);
    label = new Label("Low: ");
    label.setStyle("-fx-font-weight: bold");
    p.getChildren().addAll(label, lowLabel);
    this.setBottom(p);

    unitProperty.addListener((ObservableValue<? extends Temperature.Unit> observable, Temperature.Unit oldValue,
            Temperature.Unit newValue) -> {
        setUnits(newValue);
    });
}

From source file:Main.java

private AnchorPane addAnchorPane(GridPane grid) {

    AnchorPane anchorpane = new AnchorPane();

    Button buttonSave = new Button("Save");
    Button buttonCancel = new Button("Cancel");

    HBox hb = new HBox();
    hb.setPadding(new Insets(0, 10, 10, 10));
    hb.setSpacing(10);/*from w w  w  .ja v a  2  s .c o  m*/
    hb.getChildren().addAll(buttonSave, buttonCancel);

    anchorpane.getChildren().addAll(grid, hb);
    // Anchor buttons to bottom right, anchor grid to top
    AnchorPane.setBottomAnchor(hb, 8.0);
    AnchorPane.setRightAnchor(hb, 5.0);
    AnchorPane.setTopAnchor(grid, 10.0);

    return anchorpane;
}

From source file:account.management.controller.inventory.InsertStockController.java

@FXML
private void onSaveButtonClick(ActionEvent event) {
    this.save.setDisable(true);
    try {/*from ww w.ja v  a2 s  .c  o  m*/
        String date = new SimpleDateFormat("yyyy-MM-dd")
                .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.date.getValue().toString()));
        JSONArray array = new JSONArray();
        for (int i = 0; i < this.conatiner.getChildren().size(); i++) {
            HBox row = (HBox) this.conatiner.getChildren().get(i);
            ComboBox<Product> item = (ComboBox) row.getChildren().get(0);
            TextField qty = (TextField) row.getChildren().get(1);
            TextField rate = (TextField) row.getChildren().get(2);

            JSONObject obj = new JSONObject();
            obj.put("id", item.getSelectionModel().getSelectedItem().getId());
            obj.put("quantity", qty.getText());
            obj.put("rate", rate.getText());

            array.put(obj);

        }

        Unirest.post(MetaData.baseUrl + "products/ledger")
                .field("voucher_type", this.voucher_type.getSelectionModel().getSelectedItem())
                .field("date", date).field("products", array).asString();
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setHeaderText(null);
        alert.setContentText("Ledger has been saved successfully!");
        alert.setGraphic(new ImageView(new Image("resources/success.jpg")));
        alert.showAndWait();
        this.save.setDisable(false);
    } catch (Exception ex) {
        Logger.getLogger(InsertStockController.class.getName()).log(Level.SEVERE, null, ex);
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setHeaderText(null);
        alert.setContentText("Sorry!! there is an error. Please try again.");
        alert.setGraphic(new ImageView(new Image("resources/error.jpg")));
        alert.showAndWait();
    }
}

From source file:Main.java

HBox getButtons() {
    Region spring = new Region();
    HBox.setHgrow(spring, Priority.ALWAYS);
    HBox buttonBar = new HBox(5);
    cancelButton.setCancelButton(true);//from   ww  w  .j  a  v  a  2 s. co m
    finishButton.setDefaultButton(true);
    buttonBar.getChildren().addAll(spring, priorButton, nextButton, cancelButton, finishButton);
    return buttonBar;
}

From source file:account.management.controller.expenseVoucherController.java

@FXML
private void onSaveButtonClick(ActionEvent event) {
    try {/*from  w  w w . j a  v  a  2  s.c  om*/
        String date = "", location = "", receivers_name = "", receivers_address = "", via = "",
                via_address = "", in_word = "", total = "", expenses = "[]";
        if (!this.date.getEditor().getText().equals("")) {
            date = this.date.getValue().toString();
            date = new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("yyyy-MM-dd").parse(date));
        }
        if (!this.location.getSelectionModel().isEmpty())
            location = String.valueOf(this.location.getSelectionModel().getSelectedItem().getId());
        if (!this.receivers_name.getText().equals(""))
            receivers_name = this.receivers_name.getText();
        if (!this.receivers_address.getText().equals(""))
            receivers_address = this.receivers_address.getText();
        if (!this.via_name.getText().equals(""))
            via = this.via_name.getText();
        if (!this.via_address.getText().equals(""))
            via_address = this.via_address.getText();
        if (!this.in_word.getText().equals(""))
            in_word = this.in_word.getText();
        if (!this.total.getText().equals(""))
            total = this.total.getText();
        JSONArray expenses_array = new JSONArray();
        for (int i = 0; i < this.container.getChildren().size(); i++) {
            JSONObject obj = new JSONObject();
            HBox row = (HBox) this.container.getChildren().get(i);
            TextField desc = (TextField) row.getChildren().get(0);
            TextField amount = (TextField) row.getChildren().get(1);
            obj.put("description", desc.getText());
            obj.put("amount", amount.getText());
            expenses_array.put(obj);
        }
        expenses = expenses_array.toString();

        HttpResponse<String> res = Unirest.get(MetaData.baseUrl + "add/expenseVoucher")
                .queryString("date", date).queryString("location", location)
                .queryString("receivers_name", receivers_name)
                .queryString("receivers_address", receivers_address).queryString("via", via)
                .queryString("via_address", via_address).queryString("in_word", in_word)
                .queryString("total", total).queryString("expenses", expenses).asString();
        System.out.println(expenses);
        if (res.getBody().equals("success")) {
            Msg.showInformation("Expense voucher has been saved successfully.");

            Report report = new Report();
            Vector v = new Vector();
            HashMap params = new HashMap();
            params.put("date", new SimpleDateFormat("dd-MM-yyyy")
                    .format(new SimpleDateFormat("yyyy-MM-dd").parse(this.date.getValue().toString())));
            params.put("rcv_name", receivers_name);
            params.put("rcv_address", receivers_address);
            params.put("via_name", via);
            params.put("via_address", via_address);
            params.put("total_word", in_word);
            int sl = 1;
            for (int i = 0; i < expenses_array.length(); i++) {
                JSONObject obj = expenses_array.getJSONObject(i);
                v.add(new ExpenseVoucherEntry(String.valueOf(sl++), obj.getString("description"),
                        obj.getString("amount")));
            }
            report.getReport("src\\report\\ExpenseVoucher.jrxml", new JRBeanCollectionDataSource(v), params,
                    "Credit Voucher");

        } else {
            Msg.showError("");
        }
    } catch (Exception ex) {
        Msg.showError("");
    }

}

From source file:org.samcrow.frameviewer.ui.db.DatabaseConnectionDialog.java

public DatabaseConnectionDialog(String connectionTypeName) {
    this.connectionTypeName = connectionTypeName;
    setTitle("Database connection");
    // Placeholder
    root.getChildren().add(new Region());

    // Buttons//from w ww  . ja  v a2 s.co  m
    {
        final HBox buttonBox = new HBox();
        buttonBox.setPadding(new Insets(10));

        cancelButton.setCancelButton(true);
        buttonBox.getChildren().add(cancelButton);
        cancelButton.setOnAction((ActionEvent t) -> {
            hide();
        });

        final Region spacer = new Region();
        buttonBox.getChildren().add(spacer);
        HBox.setHgrow(spacer, Priority.ALWAYS);

        nextButton.setDefaultButton(true);
        buttonBox.getChildren().add(nextButton);

        root.getChildren().add(buttonBox);
    }

    switchToConnection();

    final Scene scene = new Scene(root, 220, root.getPrefHeight());
    setScene(scene);
}

From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java

private List<CheckBox> getCheckBoxs() {
    List<CheckBox> boxs = new ArrayList<>();
    for (Node node : vboxRadios.getChildren()) {
        HBox hbox = (HBox) node;
        if (hbox.getChildren().get(0) instanceof CheckBox) {
            boxs.add((CheckBox) hbox.getChildren().get(0));
        }/*  www  .  j a  va 2 s.  c om*/
    }
    return boxs;
}

From source file:Main.java

@Override
public void start(Stage stage) {
    HBox root = new HBox();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);//from w  ww.  java 2 s  .co m
    stage.setTitle("");

    ToggleGroup group = new ToggleGroup();
    RadioButton button1 = new RadioButton("select first");
    button1.setToggleGroup(group);
    button1.setSelected(true);
    RadioButton button2 = new RadioButton("select second");
    button2.setToggleGroup(group);

    root.getChildren().add(button1);
    root.getChildren().add(button2);

    scene.setRoot(root);
    stage.show();
}

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

private void addPlugin(TabPane tabPane, String className, String pluginName) {
    try {//from ww w.  j a va  2s .c o  m
        Class clazz = Class.forName(className);
        Constructor cons = clazz.getConstructor(TKMacTuning.class, String.class);
        AbstractPlugin plugin = (AbstractPlugin) cons.newInstance(this, pluginName);
        String primaryUICategory = plugin.getPrimaryUICategory();
        Tab tab = (Tab) tabPane.getProperties().get(primaryUICategory);
        if (tab == null) {
            tab = new Tab(primaryUICategory);
            tabPane.getProperties().put(primaryUICategory, tab);
            tabPane.getTabs().add(tab);
            VBox content = new VBox();
            content.setPadding(LayoutConstants.PADDING_1);
            content.setSpacing(LayoutConstants.VERTICAL_CONTROL_GAP);
            tab.setContent(content);
        }
        VBox content = (VBox) tab.getContent();
        Node node = plugin.getNode();
        if (node != null) {
            String secondaryUICategory = plugin.getSecondaryUICategory();
            if (AbstractPlugin.ROOT.equals(secondaryUICategory)) {
                content.getChildren().add(node);
            } else {
                Pane group = (Pane) tabPane.getProperties().get(GROUP + secondaryUICategory);
                if (group == null) {
                    group = new VBox(LayoutConstants.VERTICAL_CONTROL_GAP);
                    tabPane.getProperties().put(GROUP + secondaryUICategory, group);
                    HBox headline = new HBox();
                    headline.setStyle(
                            "-fx-border-insets: 0 0 1 0; -fx-border-color: transparent transparent -fx-text-box-border transparent; -fx-border-width: 1;");
                    headline.getChildren().add(new Label(secondaryUICategory));
                    group.getChildren().add(headline);
                    content.getChildren().add(group);
                }
                group.getChildren().add(node);
            }
        } else {
            LOGGER.log(Level.SEVERE, "could not create control for plugin {0}({1})",
                    new Object[] { className, pluginName });
        }
    } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | SecurityException
            | InvocationTargetException | IllegalAccessException ex) {
        LOGGER.log(Level.SEVERE, "addPlugin()", ex);
    }
}