cssjavafxfxmlfullscreen

Resizing ComboBox by scaling screen size


I'd like to make my application resizable. I want to resize all child elements and its font size and images depending on the height and width.

I followed the instructions on the following page: Bond Font Size and Image with Thresholds. The answer contains two approaches. The first approach works fine but the second approach does not resize the ComboBox elements. What do I need to change to make the second approach work for dropdown of ComboBoxes as well?

Example code is given here Bond Font Size and Image with Thresholds as well.


Solution

  • Try to access the scale attribute from LetterBoxer and set that scale to listView of the ComboBox while showing.

    selectCardReaderCombo.setOnShowing(e->{
        selectCardReaderCombo.getChildrenUnmodifiable().stream()
                .filter(n-> n.getStyleClass().contains("list-view"))
                .forEach(n->{
                    n.getTransforms().setAll(boxSizeAdjuster.scale);
        });
    });
    

    enter image description here