Java Program to create Arrow Button positioning North

To create Arrow Button at position north, use BasicArrowButton:

BasicArrowButton arrow = new BasicArrowButton(BasicArrowButton.NORTH);

Above, we have set the arrow to NORTH. Now add it to Panel:

panel.add(arrow, BorderLayout.NORTH);

The following is an example to create Arrow Button positioning 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.add(new SwingDemo());
      frame.setSize(600, 500);

The output is as follows displaying the arrow button positioning NORTH: