如何在Java中显示符号?
我想显示此符号:✤
我想在标签上显示此符号。我只是尝试粘贴到代码,然后尝试使用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:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您使用的字体是否可以显示此字符。但是,有时问题只是将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.