0

I'm using ControlFx's Popover to display validation messages . I'm not able to set the desired height,width and style to the popover. Below is the code I'm using.

PopOver popOver = new PopOver();
        Label messageLable = new Label();
        messageLable.setFont(Font.font(12));
        messageLable.setMinHeight(15);
        messageLable.setMaxHeight(15);
        messageLable.setMinWidth(40);
        messageLable.setText("Appropriate validation message ");
        popOver.setContentNode(messageLable);
        popOver.arrowSizeProperty().bind(new SimpleDoubleProperty(12));
        popOver.arrowIndentProperty().bind(new SimpleDoubleProperty(12));
        popOver.arrowLocationProperty().bind(new SimpleObjectProperty<>(ArrowLocation.LEFT_TOP));
        popOver.cornerRadiusProperty().bind(new SimpleDoubleProperty(5));
        popOver.hide(Duration.seconds(4));
        popOver.setDetachable(Boolean.FALSE);
        popOver.setStyle("-fx-background-color: rgb(255,0,255);");

Edit 1:

I'm able to set the style (background color etc ) from CSS .Reffered to the answer at Styling JavaFX Popover. But I'm still not able to set the desired height and width

4

1 回答 1

1

I was not able to reduce the width and height because the PopOverSkin class uses the arrowsize property , corner radius property and arrow indent property. Below is the extract from the class PopOverSkin.

/*
         * The min width and height equal 2 * corner radius + 2 * arrow indent +
         * 2 * arrow size.
         */
        stackPane.minWidthProperty().bind(
                Bindings.add(Bindings.multiply(2, popOver.arrowSizeProperty()),
                        Bindings.add(
                                Bindings.multiply(2,
                                        popOver.cornerRadiusProperty()),
                                Bindings.multiply(2,
                                        popOver.arrowIndentProperty()))));

Reducing the arrowsize , corner radius and arrow indent changed the height and width of the popover accordingly

于 2016-03-10T22:02:47.460 回答