I have a table width two columns:
Time Message
16:15 asdf asdf asdf as df asdf
16:30 foo bah bob boo
16:45 bluf
When my table view is resized, my application is supposed to keep the width of the Time column fixed, while expanding the Message column to show as much of the message as possible. To do this, I have used bindings, which works fine, but takes a lot of plumbing:
messageColumn.prefWidthProperty().bind(
myTable.widthProperty().subtract(
timeColumn.widthProperty()
).subtract(51)
);
I have to subtract 51 to avoid triggering the displaying of the horizontal scroll bar - no, this is not pretty. But instead of having to write all of this, I suggest introducing column resize policies, allowing me to replace the code above with
timeColumn.setResizePolicy(ResizePolicy.FIXED);
messageColumn.setResizePolicy(ResizePolicy.FILL);
which I think is much more easy to read and understand.
If multiple columns use the FILL policy they should split the available width while taking their preferred widths into account. So if the table's inner width is 1200px and its two columns have preferred widths of 200px and 400px their widths should be set to 400px and 800px using up all the 1200px, if both their resize policies are FILL.
Time Message
16:15 asdf asdf asdf as df asdf
16:30 foo bah bob boo
16:45 bluf
When my table view is resized, my application is supposed to keep the width of the Time column fixed, while expanding the Message column to show as much of the message as possible. To do this, I have used bindings, which works fine, but takes a lot of plumbing:
messageColumn.prefWidthProperty().bind(
myTable.widthProperty().subtract(
timeColumn.widthProperty()
).subtract(51)
);
I have to subtract 51 to avoid triggering the displaying of the horizontal scroll bar - no, this is not pretty. But instead of having to write all of this, I suggest introducing column resize policies, allowing me to replace the code above with
timeColumn.setResizePolicy(ResizePolicy.FIXED);
messageColumn.setResizePolicy(ResizePolicy.FILL);
which I think is much more easy to read and understand.
If multiple columns use the FILL policy they should split the available width while taking their preferred widths into account. So if the table's inner width is 1200px and its two columns have preferred widths of 200px and 400px their widths should be set to 400px and 800px using up all the 1200px, if both their resize policies are FILL.