JavaFX - How to create a thin MenuBar?

北城以北 提交于 2019-12-02 04:54:51

Adding the following selectors to you stylesheet reduces the height of each menu element:

.menu-item { -fx-padding: 1 5 1 5; }
.menu { -fx-padding: 1 5 1 5; }

To remove the padding of all context menus, you can additionally add:

.menu .context-menu { -fx-padding: 1 1 1 1; }

And you can also decrease the font size:

.menu-item >.label {-fx-font-size:9;}
.menu >.label {-fx-font-size:9;}

Furthermore you can remove the left right padding of the MenuBar and decrease the spacing:

.menu-bar {
  -fx-padding: 0 1 0 1;
  -fx-spacing: 1;
};

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!