javafx& fxml:如何应用边框到我的gui中的窗格或标签? [英] javafx & fxml: how do I apply a border to a pane or label in my gui?

查看:1258
本文介绍了javafx& fxml:如何应用边框到我的gui中的窗格或标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用fxml,它似乎是一个很酷的想法,除了我有一个艰难的时间让它工作的事实。假设我能够使用一个好的标记语言,我可以布局我的GUI,我可以通过CSS样式的元素。所以我在我的GUI上有一个标签,我想有一个坚实的黑色边框周围,宽度= 1。看起来像这样应该是直接 - 适应例子我看到这里和教程等,我做以下:

I'm just getting into using fxml and it seems like a really cool idea, except for the fact that I'm having a tough time getting it to work. Supposedly I'm able to lay out my GUI using a nice markup language, and I can style the elements via CSS. So I have a label on my GUI, and I would like there to be a solid black border around it, with width=1. Seems like this should be straightforward -- adapting examples I see here and there in tutorials, etc., I do the following:

<Label text="sample text" style="-fx-border-width: 1; -fx-border-style: solid;" />

但它不工作。不显示边框。在场景生成器中,在属性检查器中有一个标记为样式的文本框,我可以看到我应用的样式出现在那里,但是我没有看到边框。

But it doesn't work. No border appears. In the Scene Builder there is a text box labelled "Style" in the properties inspector, and I can see the style I have applied appear there, but I don't see a border.

我要忽略什么?

推荐答案

您还需要指定边框颜色。将此添加到您的标签标签

You need to specify the Border Color as well. Add this to your Label tab

-fx-border-color:black;

在您的情况下,示例代码将是:

In your case the sample code will be :

<Label text="sample text" style=" -fx-border-color:black; -fx-border-width: 1; -fx-border-style: solid;" />

这篇关于javafx&amp; fxml:如何应用边框到我的gui中的窗格或标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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