Java 如何在 JButton 上显示刻度线和一些文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19783765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i display a tick mark and some text on a JButton
提问by Ankit Rustagi
How can i display a tick mark like this -
我怎样才能显示这样的刻度线 -
and some text on a JButton.
和 JButton 上的一些文本。
-----------------------
| mybutton [tick-mark] |
-----------------------
Is there any way i can achieve this apart from placing an image on the button ?
除了在按钮上放置图像之外,还有什么方法可以实现这一点吗?
采纳答案by Stephen C
You could try using one of the Unicode code-points that denote a "check mark". The alternatives are listed here.
您可以尝试使用表示“复选标记”的 Unicode 代码点之一。此处列出了替代方案。
If you take this approach, your buttons may look different (or even completely wrong) on different platforms due to font issues. An image is more likely to give a consistent "look".
如果您采用这种方法,由于字体问题,您的按钮在不同平台上可能看起来不同(甚至完全错误)。图像更有可能提供一致的“外观”。