[英]Stroke text with HTML in Java Swing
I'm using this string for a Java swing JLabel: 我将此字符串用于Java swing JLabel:
"<html>\n" +
"<head><style>\n" +
"p { color: white;\n" +
" text-shadow:\n" +
" -1px -1px 0 #000,\n" +
" 1px -1px 0 #000,\n" +
" -1px 1px 0 #000,\n" +
" 1px 1px 0 #000; }" +
"</style></head>\n" +
"<body><p>testing123</p></body>\n" +
"</html>"
Which is a slightly modified example I found of how to stroke the outline around text with HTML. 我发现了一个稍作修改的示例,该示例说明了如何使用HTML在文本周围描边。 When I do this, "testing123" shows up in white (or whatever color I place of white), which is good, but no shadow or outline is ever visible, regardless of background.
当我这样做时,“ testing123”以白色(或我放置在白色处的任何颜色)显示为白色,这很好,但是无论背景如何,都看不到阴影或轮廓。 This works on the w3schools css tester page.
这在w3schools CSS测试器页面上有效。 I read that it only works on certain browsers, so I'm guessing that excludes swing?
我读到它仅在某些浏览器上有效,所以我猜想这不包括秋千吗? Is there any way to make this work?
有什么办法可以使这项工作吗?
I read that it only works on certain browsers, so I'm guessing that excludes swing?
我读到它仅在某些浏览器上有效,所以我猜想这不包括秋千吗?
You guessed right! 你猜对了! Swing's HTML support includes a sub-set of HTML 3.2 .
Swing的HTML支持包括HTML 3.2的子集 。 The CSS support is equally patchy and incomplete.
CSS支持同样不完整且不完整。
Is there any way to make this work?
有什么办法可以使这项工作吗?
The Java-FX based WebView
would seem to be the best approach. 基于Java-FX的
WebView
似乎是最好的方法。 Java-FX based components can be embedded into Swing apps. 可以将基于Java-FX的组件嵌入到Swing应用程序中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.