gpt4 book ai didi

Java - 具有显示箭头的按钮

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:03:27 25 4
gpt4 key购买 nike

我希望在 Java 中有一个显示箭头的按钮 - 就像在键盘上一样。到目前为止我有这个

JButton arrowUp = new JButton("^");
JButton arrowDown = new JButton("v");
JButton arrowLeft = new JButton("<");
JButton arrowRight = new JButton(">");

它有点管用......但看起来不太好。

感谢任何帮助如何改进这一点

最佳答案

Swing 有一个默认的箭头按钮类,即 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 - 具有显示箭头的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8502068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com