我希望我的TableView的高度适应填充的行数,因此它永远不会显示任何空行.换句话说,TableView的高度不应超出最后填充的行.我该怎么做呢?
有没有办法知道表格视图上是否存在滚动条?(除了我在下面的代码中所做的)我的目标是在桌子的右侧(桌子上方)放置 2 个箭头图像(以关闭/打开侧面板)。但我不想把它们放在滚动条上。表格内容是搜索的结果,因此有时滚动条可见,有时则不可见。如果没有足够的物品。我希望每次 tableview 项目更改时我的箭头的位置都会更改。
我已经尝试了以下解决方案,但结果是第二次搜索时箭头会移动。看起来像一个并发问题。就像在呈现表之前执行我的侦听器代码一样。
有没有办法解决这个问题?
tableView.getItems().addListener( (ListChangeListener<LogData>) c -> {
// Check if scroll bar is visible on the table
// And if yes, move the arrow images to not be over the scroll bar
Double lScrollBarWidth = null;
Set<Node> nodes = tableView.lookupAll( ".scroll-bar" );
for ( final Node node : nodes )
{
if ( node instanceof ScrollBar )
{
ScrollBar sb = (ScrollBar) node;
if ( sb.getOrientation() == Orientation.VERTICAL )
{
LOGGER.debug( "Scroll bar visible : …
Run Code Online (Sandbox Code Playgroud)