Java 程序用于创建指向北方的箭头按钮
要创建指向北方的箭头按钮,请使用 BasicArrowButton
BasicArrowButton arrow = new BasicArrowButton(BasicArrowButton.NORTH);
在上面,我们将箭头设置为 NORTH。现在将它添加到 Panel
panel.add(arrow, BorderLayout.NORTH);
以下是创建指向北方的箭头按钮的示例
示例
import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.plaf.basic.BasicArrowButton; public class SwingDemo extends JPanel { public SwingDemo() { setLayout(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout()); add(panel, BorderLayout.EAST); BasicArrowButton arrow = new BasicArrowButton(BasicArrowButton.NORTH); panel.add(arrow, BorderLayout.NORTH); } public static void main(String[] args) { JFrame frame = new JFrame("Frame with arrow"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new SwingDemo()); frame.setSize(600, 500); frame.setLocationByPlatform(true); frame.setVisible(true); } }
结果如下,显示指向 NORTH 的箭头按钮
Advertisement