Example usage for javafx.scene.layout BorderPane BorderPane

List of usage examples for javafx.scene.layout BorderPane BorderPane

Introduction

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

Prototype

public BorderPane(Node center, Node top, Node right, Node bottom, Node left) 

Source Link

Document

Creates an BorderPane layout with the given Nodes to use for each of the main layout areas of the Border Pane.

Usage

From source file:Main.java

public void start(Stage stage) {
    Node top = null;//from   w  w w. j av a2  s. co  m
    Node left = null;

    VBox center = getCenter();

    Button okBtn = new Button("Ok");
    Button cancelBtn = new Button("Cancel");

    okBtn.setMaxWidth(Double.MAX_VALUE);
    VBox right = new VBox(okBtn, cancelBtn);
    right.setStyle("-fx-padding: 10;");

    Label statusLbl = new Label("Status: Ready");
    HBox bottom = new HBox(statusLbl);
    BorderPane.setMargin(bottom, new Insets(10, 0, 0, 0));

    BorderPane root = new BorderPane(center, top, right, bottom, left);

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
}

From source file:vkmanager.controller.PhotosDetailedController.java

public void showPhotosFromAlbum(VKPhotoAlbum album, int userId) {
    this.album = album;
    idForDownload = album.getId();/*w  w  w. ja v a 2 s  .  c  o m*/
    albumDescription.setText(album.getDescription());
    photos = vkapi.getPhotosFromAlbum(idForDownload, userId);

    int i = 0;
    int j = 0;
    gridPaneDetailed.addRow(0);
    for (VKPhoto photo : photos) {
        Image photoThumbLink = new Image(photo.getLink_s());
        ImageView photoThumb = new ImageView(photoThumbLink);

        photoThumb.setFitHeight(160);
        photoThumb.setFitWidth(240);

        photoThumb.setPreserveRatio(true);
        photoThumb.setSmooth(true);
        photoThumb.setCache(true);

        Button photoButt = new Button();
        photoButt.setGraphic(photoThumb);
        photoButt.setStyle("-fx-background-color: white;");
        photoButt.setMinSize(240, 160);
        photoButt.setAlignment(Pos.CENTER);

        BorderPane bp = new BorderPane(null, photoButt, null, null, null);
        gridPaneDetailed.add(bp, j, i);

        j++;
        if (j == 3) {
            i++;
            j = 0;
            gridPaneDetailed.addRow(i);
        }
    }
}

From source file:eu.ggnet.dwoss.receipt.shipment.ShipmentUpdateStage.java

private void init(Shipment s) {

    okButton.setOnAction((ActionEvent event) -> {
        shipment = getShipment();/*from w w w.j  a  v  a2s .c  om*/
        if (isValid())
            close();
    });

    cancelButton.setOnAction((ActionEvent event) -> {
        close();
    });

    idField = new TextField(Long.toString(s.getId()));
    idField.setDisable(true);
    shipIdField = new TextField(s.getShipmentId());

    Callback<ListView<TradeName>, ListCell<TradeName>> cb = new Callback<ListView<TradeName>, ListCell<TradeName>>() {
        @Override
        public ListCell<TradeName> call(ListView<TradeName> param) {
            return new ListCell<TradeName>() {
                @Override
                protected void updateItem(TradeName item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty)
                        setText("Hersteller whlen...");
                    else
                        setText(item.getName());
                }
            };
        }
    };

    Set<TradeName> contractors = Client.lookup(MandatorSupporter.class).loadContractors().all();
    ownerBox = new ComboBox<>(FXCollections.observableArrayList(contractors));
    ownerBox.setMaxWidth(MAX_VALUE);
    ownerBox.setCellFactory(cb);
    ownerBox.getSelectionModel().selectedItemProperty().addListener(
            (ObservableValue<? extends TradeName> observable, TradeName oldValue, TradeName newValue) -> {
                if (newValue == null)
                    return;
                shipment.setContractor(newValue);
                manufacturerBox.getSelectionModel().select(newValue.getManufacturer());
            });

    ObservableList<TradeName> manufacturers = FXCollections.observableArrayList(TradeName.getManufacturers());
    manufacturerBox = new ComboBox<>(manufacturers);
    manufacturerBox.setMaxWidth(MAX_VALUE);
    manufacturerBox.setCellFactory(cb);
    SingleSelectionModel<TradeName> sm = ownerBox.getSelectionModel();
    if (s.getContractor() == null)
        sm.selectFirst();
    else
        sm.select(s.getContractor());
    if (shipment.getDefaultManufacturer() != null)
        manufacturerBox.getSelectionModel().select(shipment.getDefaultManufacturer());

    statusBox = new ComboBox<>(FXCollections.observableArrayList(Shipment.Status.values()));
    statusBox.setMaxWidth(MAX_VALUE);
    statusBox.getSelectionModel().select(s.getStatus() == null ? OPENED : s.getStatus());

    GridPane grid = new GridPane();
    grid.addRow(1, new Label("ID:"), idField);
    grid.addRow(2, new Label("Shipment ID:"), shipIdField);
    grid.addRow(3, new Label("Besitzer:"), ownerBox);
    grid.addRow(4, new Label("Hersteller:"), manufacturerBox);
    grid.addRow(5, new Label("Status"), statusBox);
    grid.setMaxWidth(MAX_VALUE);
    grid.vgapProperty().set(2.);
    grid.getColumnConstraints().add(0,
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.SOMETIMES, HPos.LEFT, false));
    grid.getColumnConstraints().add(1,
            new ColumnConstraints(100, 150, Double.MAX_VALUE, Priority.ALWAYS, HPos.LEFT, true));

    HBox hButtonBox = new HBox(okButton, cancelButton);
    hButtonBox.alignmentProperty().set(Pos.TOP_RIGHT);

    errorLabel.setWrapText(true);
    BorderPane rootPane = new BorderPane(grid, errorLabel, null, hButtonBox, null);

    this.setTitle(s.getId() > 0 ? "Shipment bearbeiten" : "Shipment anlegen");
    this.setScene(new Scene(rootPane));
    this.setResizable(false);
}

From source file:org.sleuthkit.autopsy.timeline.ui.detailview.AggregateEventNode.java

public AggregateEventNode(final AggregateEvent event, AggregateEventNode parentEventNode,
        EventDetailChart chart) {/*from  w w  w.ja  va2  s.  c  o  m*/
    this.event = event;
    descLOD.set(event.getLOD());
    this.parentEventNode = parentEventNode;
    this.chart = chart;
    final Region region = new Region();
    HBox.setHgrow(region, Priority.ALWAYS);
    final HBox hBox = new HBox(descrLabel, countLabel, region, minusButton, plusButton);
    hBox.setPrefWidth(USE_COMPUTED_SIZE);
    hBox.setMinWidth(USE_PREF_SIZE);
    hBox.setPadding(new Insets(2, 5, 2, 5));
    hBox.setAlignment(Pos.CENTER_LEFT);

    minusButton.setVisible(false);
    plusButton.setVisible(false);
    minusButton.setManaged(false);
    plusButton.setManaged(false);
    final BorderPane borderPane = new BorderPane(subNodePane, hBox, null, null, null);
    BorderPane.setAlignment(subNodePane, Pos.TOP_LEFT);
    borderPane.setPrefWidth(USE_COMPUTED_SIZE);

    getChildren().addAll(spanRegion, borderPane);

    setAlignment(Pos.TOP_LEFT);
    setMinHeight(24);
    minWidthProperty().bind(spanRegion.widthProperty());
    setPrefHeight(USE_COMPUTED_SIZE);
    setMaxHeight(USE_PREF_SIZE);

    //set up subnode pane sizing contraints
    subNodePane.setPrefHeight(USE_COMPUTED_SIZE);
    subNodePane.setMinHeight(USE_PREF_SIZE);
    subNodePane.setMinWidth(USE_PREF_SIZE);
    subNodePane.setMaxHeight(USE_PREF_SIZE);
    subNodePane.setMaxWidth(USE_PREF_SIZE);
    subNodePane.setPickOnBounds(false);

    //setup description label
    eventTypeImageView.setImage(event.getType().getFXImage());
    descrLabel.setGraphic(eventTypeImageView);
    descrLabel.setPrefWidth(USE_COMPUTED_SIZE);
    descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);

    descrLabel.setMouseTransparent(true);
    setDescriptionVisibility(chart.getDescrVisibility().get());

    //setup backgrounds
    final Color evtColor = event.getType().getColor();
    spanFill = new Background(
            new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY));
    setBackground(
            new Background(new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY)));
    setCursor(Cursor.HAND);
    spanRegion.setStyle("-fx-border-width:2 0 2 2; -fx-border-radius: 2; -fx-border-color: "
            + ColorUtilities.getRGBCode(evtColor) + ";"); // NON-NLS
    spanRegion.setBackground(spanFill);

    //set up mouse hover effect and tooltip
    setOnMouseEntered((MouseEvent e) -> {
        //defer tooltip creation till needed, this had a surprisingly large impact on speed of loading the chart
        installTooltip();
        spanRegion.setEffect(new DropShadow(10, evtColor));
        minusButton.setVisible(true);
        plusButton.setVisible(true);
        minusButton.setManaged(true);
        plusButton.setManaged(true);
        toFront();

    });

    setOnMouseExited((MouseEvent e) -> {
        spanRegion.setEffect(null);
        minusButton.setVisible(false);
        plusButton.setVisible(false);
        minusButton.setManaged(false);
        plusButton.setManaged(false);

    });

    setOnMouseClicked(new EventMouseHandler());

    plusButton.disableProperty().bind(descLOD.isEqualTo(DescriptionLOD.FULL));
    minusButton.disableProperty().bind(descLOD.isEqualTo(event.getLOD()));

    plusButton.setOnMouseClicked(e -> {
        final DescriptionLOD next = descLOD.get().next();
        if (next != null) {
            loadSubClusters(next);
            descLOD.set(next);
        }
    });
    minusButton.setOnMouseClicked(e -> {
        final DescriptionLOD previous = descLOD.get().previous();
        if (previous != null) {
            loadSubClusters(previous);
            descLOD.set(previous);
        }
    });
}