本文介绍了Java - 有按钮显示箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想在Java中有一个显示箭头的按钮 - 就像在键盘上一样。 到目前为止,我有这个I would like to have a buttons in Java which shows the arrows - like on the keyboard.So far I have thisJButton 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推荐答案 Swing有一个默认的箭头按钮类 BasicArrowButtonSwing has a default arrow button class that is BasicArrowButton示例: JFrame frame = new JFrame("Arrow Button Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new BasicArrowButton(BasicArrowButton.EAST), BorderLayout.EAST); frame.add(new BasicArrowButton(BasicArrowButton.NORTH), BorderLayout.NORTH); frame.add(new BasicArrowButton(BasicArrowButton.SOUTH), BorderLayout.SOUTH); frame.add(new BasicArrowButton(BasicArrowButton.WEST), BorderLayout.WEST); frame.pack(); frame.setVisible(true); 这篇关于Java - 有按钮显示箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-12 09:06