如何在Java中显示符号?

发布于 2025-02-13 23:34:52 字数 555 浏览 2 评论 0原文

我想显示此符号:✤

我想在标签上显示此符号。我只是尝试粘贴到代码,然后尝试使用Unicode(\ u2724),但它仅显示一个正方形。我也尝试了其他字体。

正方形的图像:

“在此处输入图像描述”

编辑:

String luck = "\u2724"; \\I tried to use the ✤ symbol too
JLabel lblLuck = new JLabel(luck);
lblLuck.setVerticalAlignment(SwingConstants.TOP);
lblLuck.setFont(new Font("Tahoma", Font.PLAIN, 30));
panel1.add(lblLuck, BorderLayout.CENTER);

I want to display this symbol: ✤

I want to appear this on a label. I tried to just paste to the code, and I tried with the Unicode (\u2724) but it shows just a square. I tried other fonts too.

Image of the square:

enter image description here

Edit:

String luck = "\u2724"; \\I tried to use the ✤ symbol too
JLabel lblLuck = new JLabel(luck);
lblLuck.setVerticalAlignment(SwingConstants.TOP);
lblLuck.setFont(new Font("Tahoma", Font.PLAIN, 30));
panel1.add(lblLuck, BorderLayout.CENTER);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一瞬间的火花 2025-02-20 23:34:52

检查您使用的字体是否可以显示此字符。但是,有时问题只是将Java文件中的代码保存在Unicode以外的其他编码中。确保代码文件编码是Unicode。

Check that the font you are using can display this character. However, sometimes the problem is just that the code in the java file is saved in an encoding other than unicode. Make sure that the code file encoding is unicode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文