I have a situation where the context menu could potentially contain hundreds of menu items. By default, the scroll buttons at the top / bottom of the popup window will be displayed in the context menu, but it occupies the full height of the screen. I tried to set the values ββof maxHeight and prefHeight, but this did not affect.
Ideally, I would like to show the scroll bar instead of the scroll buttons at the top and bottom (i.e. put it in the scroll bar).
Here is the code snippet that I currently have:
ContextMenu menu = new ContextMenu(); menu.setMaxHeight(500); menu.setPrefHeight(500); for(TabFX<T> tab : overflowTabs) { MenuItem item = new MenuItem(tab.getTabName()); if (tab.getGraphic() != null) item.setGraphic(tab.getGraphic()); item.setOnAction(e -> { select(tab); layoutTabs(); }); menu.getItems().add(item); } Point2D p = overflowBtn.localToScreen(0, overflowBtn.getHeight()); menu.show(overflowBtn, p.getX(), p.getY());
Is there a workaround for this?
source share