Java Code Examples for javafx.scene.layout.HBox#setFillHeight()

The following examples show how to use javafx.scene.layout.HBox#setFillHeight() . 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: NotificationBarPane.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
public NotificationBarPane(Node content) {
    super(content);
    progressBar = new ProgressBar();
    label = new Label("infobar!");
    bar = new HBox(label);
    bar.setMinHeight(0.0);
    bar.getStyleClass().add("info-bar");
    bar.setFillHeight(true);
    setBottom(bar);
    // Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
    sceneProperty().addListener(o -> {
        if (getParent() == null) return;
        getParent().applyCss();
        getParent().layout();
        barHeight = bar.getHeight();
        bar.setPrefHeight(0.0);
    });
    items = FXCollections.observableArrayList();
    items.addListener((ListChangeListener<? super Item>) change -> {
        config();
        showOrHide();
    });
}
 
Example 2
Source File: Demo.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private HBox getCountryItem(final Flag flag, final String text, final String data) {
    ImageView imageView = new ImageView(flag.getImage(22));
    HBox.setHgrow(imageView, Priority.NEVER);

    Label name = new Label(text);
    name.setTextFill(Tile.FOREGROUND);
    name.setAlignment(Pos.CENTER_LEFT);
    HBox.setHgrow(name, Priority.NEVER);

    Region spacer = new Region();
    spacer.setPrefSize(5, 5);
    HBox.setHgrow(spacer, Priority.ALWAYS);

    Label views = new Label(data);
    views.setTextFill(Tile.FOREGROUND);
    views.setAlignment(Pos.CENTER_RIGHT);
    HBox.setHgrow(views, Priority.NEVER);

    HBox hBox = new HBox(5, imageView, name, spacer, views);
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.setFillHeight(true);

    return hBox;
}
 
Example 3
Source File: ChargeSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    for (int i = 0 ; i < 12 ; i++) {
        Region bar = new Region();
        bar.setPrefSize(20, 20 + (i * 4));
        bars[i] = bar;
    }

    pane = new HBox(bars);
    pane.setSpacing(PREFERRED_WIDTH * 0.01960784);
    pane.setAlignment(Pos.BOTTOM_CENTER);
    pane.setFillHeight(false);
    pane.setBackground(new Background(new BackgroundFill(backgroundPaint, new CornerRadii(1024), Insets.EMPTY)));
    pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(borderWidth))));

    getChildren().setAll(pane);
}
 
Example 4
Source File: NotificationBarPane.java    From thunder with GNU Affero General Public License v3.0 6 votes vote down vote up
public NotificationBarPane (Node content) {
    super(content);
    progressBar = new ProgressBar();
    label = new Label("infobar!");
    bar = new HBox(label);
    bar.setMinHeight(0.0);
    bar.getStyleClass().add("info-bar");
    bar.setFillHeight(true);
    setBottom(bar);
    // Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
    sceneProperty().addListener(o -> {
        if (getParent() == null) {
            return;
        }
        getParent().applyCss();
        getParent().layout();
        barHeight = bar.getHeight();
        bar.setPrefHeight(0.0);
    });
    items = FXCollections.observableArrayList();
    items.addListener((ListChangeListener<? super Item>) change -> {
        config();
        showOrHide();
    });
}
 
Example 5
Source File: NotificationBarPane.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
public NotificationBarPane(Node content) {
    super(content);
    progressBar = new ProgressBar();
    label = new Label("infobar!");
    bar = new HBox(label);
    bar.setMinHeight(0.0);
    bar.getStyleClass().add("info-bar");
    bar.setFillHeight(true);
    setBottom(bar);
    // Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
    sceneProperty().addListener(o -> {
        if (getParent() == null) return;
        getParent().applyCss();
        getParent().layout();
        barHeight = bar.getHeight();
        bar.setPrefHeight(0.0);
    });
    items = FXCollections.observableArrayList();
    items.addListener((ListChangeListener<? super Item>) change -> {
        config();
        showOrHide();
    });
}
 
Example 6
Source File: NotificationBarPane.java    From devcoretalk with GNU General Public License v2.0 6 votes vote down vote up
public NotificationBarPane(Node content) {
    super(content);
    progressBar = new ProgressBar();
    label = new Label("infobar!");
    bar = new HBox(label);
    bar.setMinHeight(0.0);
    bar.getStyleClass().add("info-bar");
    bar.setFillHeight(true);
    setBottom(bar);
    // Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
    sceneProperty().addListener(o -> {
        if (getParent() == null) return;
        getParent().applyCss();
        getParent().layout();
        barHeight = bar.getHeight();
        bar.setPrefHeight(0.0);
    });
    items = FXCollections.observableArrayList();
    items.addListener((ListChangeListener<? super Item>) change -> {
        config();
        showOrHide();
    });
}
 
Example 7
Source File: NotificationBarPane.java    From thundernetwork with GNU Affero General Public License v3.0 6 votes vote down vote up
public NotificationBarPane(Node content) {
    super(content);
    progressBar = new ProgressBar();
    label = new Label("infobar!");
    bar = new HBox(label);
    bar.setMinHeight(0.0);
    bar.getStyleClass().add("info-bar");
    bar.setFillHeight(true);
    setBottom(bar);
    // Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
    sceneProperty().addListener(o -> {
        if (getParent() == null) return;
        getParent().applyCss();
        getParent().layout();
        barHeight = bar.getHeight();
        bar.setPrefHeight(0.0);
    });
    items = FXCollections.observableArrayList();
    items.addListener((ListChangeListener<? super Item>) change -> {
        config();
        showOrHide();
    });
}
 
Example 8
Source File: Demo.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    HBox lcd = new HBox();
    lcd.setPadding(new Insets(15, 15, 15, 15));
    lcd.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
    lcd.setSpacing(10);
    lcd.setAlignment(Pos.CENTER);
    lcd.setFillHeight(false);
    HBox.setMargin(seg3, new Insets(0, 20, 0, 0));
    lcd.getChildren().addAll(seg0, seg1, seg2, seg3, seg4, seg5);
    /*
    for (int i = 0 ; i < 256 ; i++) {
        System.out.println(i + "   :   " + Character.toString((char) i));
    }
    */
    StackPane pane = new StackPane();
    pane.getChildren().setAll(lcd);

    Scene scene = new Scene(pane, Color.BLACK);

    stage.setTitle("Sixteen Segment DemoGauge");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 9
Source File: Demo.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    HBox lcd = new HBox();
    lcd.setPadding(new Insets(15, 15, 15, 15));
    lcd.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
    lcd.setSpacing(10);
    lcd.setAlignment(Pos.CENTER);
    lcd.setFillHeight(false);
    HBox.setMargin(seg3, new Insets(0, 20, 0, 0));
    lcd.getChildren().addAll(seg0, seg1, seg2, seg3);
    /*
    for (int i = 0 ; i < 256 ; i++) {
        System.out.println(i + "   :   " + Character.toString((char) i));
    }
    */
    StackPane pane = new StackPane();
    pane.getChildren().setAll(lcd);

    Scene scene = new Scene(pane, Color.BLACK);

    stage.setTitle("SevenSegment DemoGauge");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 10
Source File: SearchBox.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void populateMenu(Map<DocumentType, List<SearchResult>> results) {
    contextMenu.getItems().clear();
    for (Map.Entry<DocumentType, List<SearchResult>> entry : results.entrySet()) {
        boolean first = true;
        for(SearchResult result: entry.getValue()) {
            final SearchResult sr = result;
            final HBox hBox = new HBox();
            hBox.setFillHeight(true);
            Label itemLabel = new Label(result.getName());
            itemLabel.getStyleClass().add("item-label");
            if (first) {
                first = false;
                Label groupLabel = new Label(result.getDocumentType().getPluralDisplayName());
                groupLabel.getStyleClass().add("group-label");
                groupLabel.setAlignment(Pos.CENTER_RIGHT);
                groupLabel.setMinWidth(USE_PREF_SIZE);
                groupLabel.setPrefWidth(70);
                hBox.getChildren().addAll(groupLabel,itemLabel);
            } else {
                Region spacer = new Region();
                spacer.setMinWidth(USE_PREF_SIZE);
                spacer.setPrefWidth(70);
                hBox.getChildren().addAll(spacer,itemLabel);
            }
            // create a special node for hiding/showing popup content
            final Region popRegion = new Region();
            popRegion.getStyleClass().add("search-menu-item-popup-region");
            popRegion.setPrefSize(10, 10);
            hBox.getChildren().add(popRegion);
            final String name = (result.getDocumentType() == DocumentType.SAMPLE) ? result.getName() :
                    result.getPackageName()+
                            ((result.getClassName() != null) ? "."+result.getClassName() : "") +
                            ((result.getName() != null) ? "."+result.getName() : "");
            final String shortDescription = (result.getShortDescription().length() == 160) ? result.getShortDescription() +"..." : result.getShortDescription();
            popRegion.opacityProperty().addListener(new ChangeListener<Number>() {
                @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                    Platform.runLater( new Runnable() { // TODO runLater used here as a workaround for RT-14396
                        @Override public void run() {
                            if (popRegion.getOpacity() == 1) {
                                infoName.setText(name);
                                infoDescription.setText(shortDescription);
                                Point2D hBoxPos = hBox.localToScene(0, 0);
                                extraInfoPopup.show(getScene().getWindow(),
                                    hBoxPos.getX() + contextMenu.getScene().getX() + contextMenu.getX() - infoBox.getPrefWidth() - 10,
                                    hBoxPos.getY() + contextMenu.getScene().getY() + contextMenu.getY() - 27
                                );
                            }
                        }
                    });
                }
            });
            // create menu item
            CustomMenuItem menuItem = new CustomMenuItem(hBox, true);
            menuItem.getStyleClass().add("search-menu-item");
            contextMenu.getItems().add(menuItem);
            // handle item selection
            menuItem.setOnAction(new EventHandler<ActionEvent>() {
                @Override public void handle(ActionEvent actionEvent) {
                    ///System.out.println("SearchBox.handle menuItem.setOnAction");
                    Ensemble2.getEnsemble2().goToPage(sr.getEnsemblePath(),true);
                }
            });
        }
    }
}
 
Example 11
Source File: SearchBox.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void populateMenu(Map<DocumentType, List<SearchResult>> results) {
    contextMenu.getItems().clear();
    for (Map.Entry<DocumentType, List<SearchResult>> entry : results.entrySet()) {
        boolean first = true;
        for(SearchResult result: entry.getValue()) {
            final SearchResult sr = result;
            final HBox hBox = new HBox();
            hBox.setFillHeight(true);
            Label itemLabel = new Label(result.getName());
            itemLabel.getStyleClass().add("item-label");
            if (first) {
                first = false;
                Label groupLabel = new Label(result.getDocumentType().getPluralDisplayName());
                groupLabel.getStyleClass().add("group-label");
                groupLabel.setAlignment(Pos.CENTER_RIGHT);
                groupLabel.setMinWidth(USE_PREF_SIZE);
                groupLabel.setPrefWidth(70);
                hBox.getChildren().addAll(groupLabel,itemLabel);
            } else {
                Region spacer = new Region();
                spacer.setMinWidth(USE_PREF_SIZE);
                spacer.setPrefWidth(70);
                hBox.getChildren().addAll(spacer,itemLabel);
            }
            // create a special node for hiding/showing popup content
            final Region popRegion = new Region();
            popRegion.getStyleClass().add("search-menu-item-popup-region");
            popRegion.setPrefSize(10, 10);
            hBox.getChildren().add(popRegion);
            final String name = (result.getDocumentType() == DocumentType.SAMPLE) ? result.getName() :
                    result.getPackageName()+
                            ((result.getClassName() != null) ? "."+result.getClassName() : "") +
                            ((result.getName() != null) ? "."+result.getName() : "");
            final String shortDescription = (result.getShortDescription().length() == 160) ? result.getShortDescription() +"..." : result.getShortDescription();
            popRegion.opacityProperty().addListener(new ChangeListener<Number>() {
                @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                    Platform.runLater( new Runnable() { // TODO runLater used here as a workaround for RT-14396
                        @Override public void run() {
                            if (popRegion.getOpacity() == 1) {
                                infoName.setText(name);
                                infoDescription.setText(shortDescription);
                                Point2D hBoxPos = hBox.localToScene(0, 0);
                                extraInfoPopup.show(getScene().getWindow(),
                                    hBoxPos.getX() + contextMenu.getScene().getX() + contextMenu.getX() - infoBox.getPrefWidth() - 10,
                                    hBoxPos.getY() + contextMenu.getScene().getY() + contextMenu.getY() - 27
                                );
                            }
                        }
                    });
                }
            });
            // create menu item
            CustomMenuItem menuItem = new CustomMenuItem(hBox, true);
            menuItem.getStyleClass().add("search-menu-item");
            contextMenu.getItems().add(menuItem);
            // handle item selection
            menuItem.setOnAction(new EventHandler<ActionEvent>() {
                @Override public void handle(ActionEvent actionEvent) {
                    ///System.out.println("SearchBox.handle menuItem.setOnAction");
                    Ensemble2.getEnsemble2().goToPage(sr.getEnsemblePath(),true);
                }
            });
        }
    }
}
 
Example 12
Source File: FoxEatsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 4 votes vote down vote up
public FoxEatsDemoView(FoxEatsDemo demo, Application.Parameters params) {
    this.demo = demo;
    
    // Extract api key from arguments
    apiKey = params.getUnnamed().get(0).substring(2).trim();
    
    setBackground(new Background(new BackgroundFill(Color.WHITE, null, null)));
    
    // LeftMargin And RightMargin
    HBox h = new HBox();
    h.prefWidthProperty().bind(widthProperty().divide(20));
    h.setFillHeight(true);
    HBox h2 = new HBox();
    h2.prefWidthProperty().bind(widthProperty().divide(20));
    h2.setFillHeight(true);
    
    // StackPane: Center panel, z:0 CorticalLogoPane, z:1 VBox w/main content
    StackPane stack = new StackPane();
    stack.prefWidthProperty().bind(widthProperty().multiply(9.0/10.0));
    stack.prefHeightProperty().bind(heightProperty());
    
    //////////////////////////////
    //    Z:0 background logo   //
    //////////////////////////////
    CorticalLogoBackground backGround = new CorticalLogoBackground(stack);
    backGround.setOpacity(0.2);
    
    //////////////////////////////
    // Z:1 Main Content in VBox //
    //////////////////////////////
    VBox vBox = new VBox();
    vBox.setSpacing(20);
    vBox.prefWidthProperty().bind(stack.widthProperty());
    vBox.prefHeightProperty().bind(new SimpleDoubleProperty(100.0));
    
    LogoTitlePane header = new LogoTitlePane();
    header.setTitleText("What Does A Fox Eat?");
    header.setSubTitleText("an example of using Numenta's Hierarchical Temporal Memory with Cortical.io's Semantic Folding...");
    
    HBox buttonBar = createSegmentedButtonBar();
    
    LabelledRadiusPane inputPane = getDisplayPane();
    vBox.getChildren().addAll(header, buttonBar, inputPane);
    
    stack.getChildren().addAll(backGround, vBox);
    
    // Main Layout: 3 columns, 1 row
    add(h, 0, 0);
    add(stack, 1, 0);
    add(h2, 2, 0);
    
    Platform.runLater(() -> {
        Thread t = new Thread() {
            public void run() { try{ 
                Thread.sleep(100);}catch(Exception e) {}
                Platform.runLater(() -> {
                    getScene().getWindow().setWidth(getScene().getWindow().getWidth() + 10);
                    vBox.layoutBoundsProperty().addListener((v, o, n) -> {
                        inputPane.setPrefHeight(vBox.getLayoutBounds().getHeight() - inputPane.getLayoutY() - 50);
                    });                       
                });
            }
        };
        t.start();
    });
   
}
 
Example 13
Source File: BreakingNewsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 4 votes vote down vote up
public BreakingNewsDemoView() {
    setBackground(new Background(new BackgroundFill(Color.WHITE, null, null)));
    
    // LeftMargin And RightMargin
    HBox h = new HBox();
    h.prefWidthProperty().bind(widthProperty().divide(20));
    h.setFillHeight(true);
    HBox h2 = new HBox();
    h2.prefWidthProperty().bind(widthProperty().divide(20));
    h2.setFillHeight(true);
    
    // StackPane: Center panel, z:0 CorticalLogoPane, z:1 VBox w/main content
    StackPane stack = new StackPane();
    stack.prefWidthProperty().bind(widthProperty().multiply(9.0/10.0));
    stack.prefHeightProperty().bind(heightProperty());
    
    //////////////////////////////
    //    Z:0 background logo   //
    //////////////////////////////
    CorticalLogoBackground backGround = new CorticalLogoBackground(stack);
    backGround.setOpacity(0.2);
    
    //////////////////////////////
    // Z:1 Main Content in VBox //
    //////////////////////////////
    VBox vBox = new VBox();
    vBox.setSpacing(20);
    vBox.prefWidthProperty().bind(stack.widthProperty());
    vBox.prefHeightProperty().bind(new SimpleDoubleProperty(100.0));
    
    LogoTitlePane header = new LogoTitlePane();
    header.setTitleText("Breaking News");
    header.setSubTitleText("a Twitter trend tracking demo...");
    
    HBox buttonBar = createSegmentedButtonBar();
    
    DualPanel inputPane = createInputPane();
    inputPane.panelHeightProperty().setValue(105);        
    
    LabelledRadiusPane chartPane = new LabelledRadiusPane("Trend");
    chartPane.getChildren().add(createChart(chartPane));
    
    SegmentedButtonBar log = createShowLogButton(vBox);
    BorderPane logButton = new BorderPane();
    logButton.prefWidthProperty().bind(vBox.widthProperty());
    logButton.setPrefHeight(10);
    logButton.setCenter(log);
    
    TriplePanel fpDisplay = createFingerprintDisplay();
    LabelledRadiusPane loggerPane = createActivityPane();
    loggerPane.prefWidthProperty().bind(fpDisplay.widthProperty());
    loggerPane.prefHeightProperty().bind(fpDisplay.heightProperty());
    
    RadiusFlipPane flip = new RadiusFlipPane(fpDisplay, loggerPane);
    fpDisplay.prefWidthProperty().bind(vBox.widthProperty());
    flipPaneProperty.set(flip);
    
    vBox.getChildren().addAll(header, buttonBar, inputPane, chartPane, logButton, flip);
    
    stack.getChildren().addAll(backGround, vBox);
    
    // Main Layout: 3 columns, 1 row
    add(h, 0, 0);
    add(stack, 1, 0);
    add(h2, 2, 0);
}
 
Example 14
Source File: BreakingNewsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates the monitor view
 * @return
 */
public LabelledRadiusPane createActivityPane() {
    LabelledRadiusPane retVal = new LabelledRadiusPane("Activity Monitor");
    HBox h = new HBox();
    h.setFillHeight(true);
    h.setSpacing(15);
    h.setPadding(new Insets(0, 10, 10, 15));
    h.prefWidthProperty().bind(retVal.widthProperty());
    h.layoutYProperty().bind(retVal.labelHeightProperty().add(20));
    
    TextArea area = new TextArea();
    area.prefWidthProperty().bind(h.widthProperty().subtract(30).divide(2));
    area.prefHeightProperty().bind(retVal.heightProperty().subtract(60));
    area.setLayoutY(retVal.labelHeightProperty().add(0).get());
    leftActivityPanelProperty.set(area);
    
    TextArea area2 = new TextArea();
    area2.prefWidthProperty().bind(h.widthProperty().subtract(60).divide(2));
    area2.prefHeightProperty().bind(retVal.heightProperty().subtract(60));
    area2.setLayoutY(retVal.labelHeightProperty().add(0).get());
    area2.textProperty().addListener((v, o, n) -> {
        area2.setScrollTop(Double.MAX_VALUE);
        area2.setScrollLeft(Double.MAX_VALUE);
    });
    rightActivityPanelProperty.set(area2);
    h.getChildren().addAll(area, area2);
    
    Label l = new Label("Output");
    l.setFont(Font.font("Helvetica", FontWeight.BOLD, 14));
    l.setTextFill(Color.rgb(00, 70, 107));
    l.layoutXProperty().bind(area.widthProperty().divide(2).add(area.getLayoutX()).subtract(l.getWidth()));
    l.setLayoutY(area.getLayoutY() - l.getHeight());
    
    Label l2 = new Label("Similar Tweets");
    l2.setFont(Font.font("Helvetica", FontWeight.BOLD, 14));
    l2.setTextFill(Color.rgb(00, 70, 107));
    area2.layoutBoundsProperty().addListener((v, o, n) -> {
        l2.setLayoutX(area.getWidth() + 60 + area2.getWidth() / 2 - l2.getWidth());
    });
    l2.setLayoutY(area2.getLayoutY() - l.getHeight());
    
    retVal.getChildren().addAll(h, l, l2);
    
    return retVal;
}