Java - 具有显示箭头的按钮
我想要一个 Java 中的按钮,它显示箭头 - 就像键盘上一样。 到目前为止,我有这个
JButton arrowUp = new JButton("^");
JButton arrowDown = new JButton("v");
JButton arrowLeft = new JButton("<");
JButton arrowRight = new JButton(">");
它有点工作......但看起来不太好。
任何有关如何改进这一点的帮助将不胜感激
I would like to have a buttons in Java which shows the arrows - like on the keyboard.
So far I have this
JButton arrowUp = new JButton("^");
JButton arrowDown = new JButton("v");
JButton arrowLeft = new JButton("<");
JButton arrowRight = new JButton(">");
It kinda works ... but does not look quite nice.
Any help how to improve this is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Swing 有一个默认的箭头按钮类
BasicArrowButton
示例:
Swing has a default arrow button class that is
BasicArrowButton
Example:
在按钮上使用 ImageIcon,或者Swing BasicArrowButtons 可能是最好的方法。不过,您也也可以使用 Unicode 箭头符号。例如
\u25C4
: ◄\u2190
: ←\u25BA
: ►\u2192
: →一些资源:
您需要确保您的应用程序可能使用的字体支持这些符号。
Using an ImageIcon on the button, or one of the Swing BasicArrowButtons is probably the best approach. However, you could also use Unicode arrow symbols. For example
\u25C4
: ◄\u2190
: ←\u25BA
: ►\u2192
: →Some resources:
You would need to ensure that the font(s) your application may use supports these symbols.
只需使用图像:
Just use a image: