Creating a slider in SWT

Main.java:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Slider;
 
public class Main {
   public static void main (String [] args) {
      Display display = new Display ();
      Shell shell = new Shell (display);
    
      shell.setBounds(200, 200, 250, 250);   
       
      Slider slider = new Slider (shell, SWT.VERTICAL);
      slider.setBounds (10, 10, 20, 200);
      final StyledText styledText = new StyledText(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
      styledText.setBounds(40, 10, 190, 200);
       
      slider.addListener (SWT.Selection, new Listener () {
         public void handleEvent (Event event) {
            String evt = "SWT.NONE";
            switch (event.detail) {
               case SWT.ARROW_DOWN: 
                  evt = "SWT.ARROW_DOWN";
                  break;
               case SWT.ARROW_UP: 
                  evt = "SWT.ARROW_UP"; 
                  break;
               case SWT.PAGE_DOWN: 
                  evt = "SWT.PAGE_DOWN"; 
                  break;
               case SWT.PAGE_UP: 
                  evt = "SWT.PAGE_UP"; 
                  break;
               case SWT.HOME: 
                  evt = "SWT.HOME"; 
                  break;
               case SWT.END: 
                  evt = "SWT.END"; 
                  break;
               case SWT.DRAG: 
                  evt = "SWT.DRAG"; 
                  break;
            }
            styledText.append(evt + "n");
            int offset = styledText.getOffsetAtLine(styledText.getLineCount()-1);
            styledText.setCaretOffset(offset);
            styledText.showSelection();
         }
      });
 
      shell.open ();
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch ()) display.sleep ();
      }
   }
}