Pregunta

    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 ?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top