作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 Windows 中,您可以组合字符来构建图标:
在 Javafx 中是否有等效的方法来为 Javafx 按钮创建图标?
(最好是 FXML)
编辑:以下是我目前在 FXML 中添加按钮的方法:
<Button text="">
<font>
<Font name="Segoe MDL2 Assets" size="14.0" />
</font>
</Button>
答案:
在下面的答案的帮助下,我使用了这个 FXML:
<Button>
<graphic>
<StackPane style="-fx-background-color: transparent;">
<Label text="A" />
<Label text="B" />
</StackPane>
</graphic>
</Button>
最佳答案
为了演示它,我使用这两个图像:
构建一个如下所示的按钮:
堆叠图像并用作按钮的图形节点:
private static final String[] images = {
"https://i.imgur.com/g52UeNO.png",
"https://i.imgur.com/kvHOLJ4.jpg",
};
ImageView imageView1 = new ImageView(images[0]);
ImageView imageView2 = new ImageView(images[1]);
StackPane sp = new StackPane(imageView1, imageView2);
Button button = new Button("", sp);
编辑:要堆叠字符,请使用:
Text t1 = new Text(Character.toString('O'));
t1.setFont(Font.font ("Verdana", 20));
t1.setFill(Color.RED);
Text t2 = new Text(Character.toString('x'));
t2.setFont(Font.font ("Verdana", 12));
t1.setFill(Color.BLUE);
StackPane sp = new StackPane(t1, t2);
Button button = new Button("", sp);
关于java - 如何在Javafx中组合字符来创建图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57940345/
我是一名优秀的程序员,十分优秀!