更改JavaFX MenuButton图标 [英] Change JavaFX MenuButton Icon

查看:51
本文介绍了更改JavaFX MenuButton图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以将JavaFX MenuButton箭头更改为字符或将其完全隐藏?

Is there a simple way to change a JavaFX MenuButton arrow to a character or hide it completely?

MenuButton hamburgerMenu = new MenuButton("\u2630");
hamburgerMenu.getItems().addAll(new MenuItem("Ham"), new MenuItem("Buger"));

推荐答案

添加以下样式以隐藏箭头

Add the following style to hide the arrow

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

结果

您还可以使用-fx-shape后跟SVG路径来定义其他SHAPE.

You can also define a different SHAPE using -fx-shape followed by a SVG path.

.menu-button > .arrow-button > .arrow {
    -fx-shape: "M 0 -3.5 v 7 l 4 -3.5 z";
}

输出为

这篇关于更改JavaFX MenuButton图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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