Using an ArrowButton in SWT

Main.java:

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
 
public class Main {
   public static void main(String[] args) {
      Display display = new Display();
      Shell shell = new Shell(display);
 
      // pos x, pos y, width, height
      shell.setBounds(200, 200, 300, 200);
      shell.setText("SWT ToggleButton Demonstration");
      shell.setLayout(new GridLayout());
 
      Group buttonGroup = new Group(shell, SWT.NONE);
      GridLayout gridLayout = new GridLayout();
      gridLayout.numColumns = 4;
      buttonGroup.setLayout(gridLayout);
      buttonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 
      SelectionListener selectionListener = new SelectionAdapter () {
         public void widgetSelected(SelectionEvent event) {
            System.out.println("integer value for alignment: " + ((Button) event.widget).getAlignment());
         };
      };
 
      createArrowButton(buttonGroup, SWT.LEFT, selectionListener);
      createArrowButton(buttonGroup, SWT.RIGHT, selectionListener);
      createArrowButton(buttonGroup, SWT.UP, selectionListener);
      createArrowButton(buttonGroup, SWT.DOWN, selectionListener);
      
      shell.open();
 
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch()) {
            display.sleep();
         }
      }
      display.dispose();
   }
   
   public static void createArrowButton(Composite parent, int alignment, 
                                          SelectionListener selectionListener) {
      GridData gridData = new GridData();
      gridData.widthHint = 30;
      gridData.heightHint = 30;
      Button button = new Button(parent, SWT.ARROW);
      button.setLayoutData(gridData);
      button.setAlignment(alignment);
      button.addSelectionListener(selectionListener);
   }
}