JavaFX 2 Not Resizing UI Control Based On Window S

2019-07-08 08:37发布

I'm new to JavaFX and I want to learn. I have a Group containing a GridPane that contains a lineChart, TableView and HBox (status bar) but I'm experiencing the following problem:

  1. I am using screen resolution 800 x 600 on Windows XP when I change the screen resolution to 1024 x 768, the lineChart, TableView and HBox does not expand to fill the new window size, it leaves a large space at the right. How can I make controls fill the width of the window when window is resized.

  2. The TableView's height extends beyond the boundary of the window, the bottom border of the tableView and the status bar is not showing. How can I make sure that the tableView does not extend beyond the window height?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-07-08 09:05

you should use userComputed size (height,and width) property.

查看更多
迷人小祖宗
3楼-- · 2019-07-08 09:08

How can I make controls fill the width of the window when window is resized.

Instead of using a Group as the root of your Scene, just make the GridPane the root of your scene.

The layout Pane classes automatically expand and shrink to fit their available area as the area changes whereas a Group does not.

How can I make sure that the tableView does not extend beyond the window height?

Your scene will probably end up being completely enclosed in the window if you just make the change above and use a layout pane as the scene root.

Additionally, if the sum of the minimum sizes of the window elements is greater than the window size, then the TableView will extend beyond the boundaries of the window, in which case you can either reduce the minimum sizes of elements (by using smaller fonts or less text, explicitly setting minWidth/minHeight values etc.) or wrap elements in a ScrollPane - but in your case those modifications are probably unnecessary.

查看更多
登录 后发表回答