문제

    TextField t1 = new TextField();
    t1.setMaxHeight(50);
    t1.setMaxWidth(140);

This is the code I use to define a TextField in JavaFX. I think setMaxHeight() method is not working because size is not changing even if the value is changed.

So I tried setPrefSize(), but it too has a problem. The height property is working fine in it, but width is larger than I specified.

How to solve the above issue ?

도움이 되었습니까?

해결책

This is very similar to how swing components work with a layout manager. In javafx the parent pane will adjust the size of nodes so a size that fits. I bet if you give the pane more room the nodes will fill out to their preferred size.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top