删除JavaFX menuButton上的箭头 [英] Remove arrow on JavaFX menuButton

查看:200
本文介绍了删除JavaFX menuButton上的箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好JavaFX样式表专家,

Hi JavaFX Stylesheet expert,

如何删除JavaFX menuButton上的默认箭头。

How do I remove the default arrow on JavaFX menuButton.

I已经想出了如何改变颜色并使其变得不可见

I have figured how to change the color and make in unvisible with

.menu-button {
    -fx-mark-color: transparent;
}

.menu-button .arrow {
    -fx-background-color: transparent;
}

但是,由于箭头不可见,我不想要这个差距。

but, I don't want the gap because of the unvisible arrow.

感谢您的建议。

最好的问候,

Ivan

推荐答案

如果我们查看 MenuButtonSkinBase的源代码 MenuButton 的子结构似乎是

If we look into the source code of MenuButtonSkinBase, the sub structure of MenuButton seems to be

MenuButton
   |——— label (LabeledImpl)
   |——— arrowButton (StackPane)
            |——— arrow (StackPane)

因此要隐藏箭头,只需将两个StackPanes的填充设置为0:

So to hide the "arrow" it is enough to set padding to 0 for both StackPanes:

.menu-button > .arrow-button {
    -fx-padding: 0;
}

.menu-button > .arrow-button > .arrow {
    -fx-padding: 0;
}

这篇关于删除JavaFX menuButton上的箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆