问题描述
我喜欢使用由BorderFactory.createLoweredBevelBorder()创建的边框的JTextField的3D效果。现在我使用JavaFX,边框的L& F由CSS控制。而默认看起来只是一个简单的笔画边框。我想出了如何编辑CSS文件以加粗边框并更改其颜色:
I like the 3D effect of a JTextField with Borders created by BorderFactory.createLoweredBevelBorder(). Now that I'm working with JavaFX instead, the L&F of the border is controlled by CSS. And the default look is just a simple line stroke border. I figured out how to edit the CSS file to thicken the border and change its color:
.text-field { -fx-border-color: color; -fx-border-width: #; }
但是,如果你看一个Swing生成的降低的斜角效果, 2,并且具有45度角的边缘阻挡件。那么如何使用CSS完成它呢?
But if you look at a Swing-generated lowered bevel effect it is created by having different colors on 2 of the 4 sides and having the edge barrier at a 45 degree angle. So how do I accomplish that with CSS?
推荐答案
说:
/ code>或
border-top
,而其他则属于此不支持的类别。
要降低斜角边框,请尝试
border
or border-top
and others are ones in this unsupported category.
To have a lowered bevel border try
.text-field {
-fx-border-insets: 0;
-fx-border-width: 2px;
-fx-border-color: black lightgray lightgray black;
}
或使用内部阴影以JavaFX风格的方式尝试
Or try with JavaFX-style way using inner shadow
.text-field {
-fx-effect: innershadow(three-pass-box, gray, 12 , 0.5, 1, 1);
}
然而,你想要的真正风格可以通过 -fx-border-style
属性IMO。请参阅上述指南。
However the real style you wanted can be achieved by -fx-border-style
attribute IMO. Refer to it in over mentioned guide.
这篇关于如何给JavaFX TextField一个Swing式降低的斜面边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!