public static void main(String[] args) {
   final Display display = new Display();
   final Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
   styledText.setText(text);
   FontData data = display.getSystemFont().getFontData()[0];
   Font font = new Font(display, data.getName(), 16, SWT.BOLD);
   styledText.setFont(font);
   styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
   styledText.addListener(
       SWT.Resize,
       new Listener() {
         public void handleEvent(Event event) {
           Rectangle rect = styledText.getClientArea();
           Image newImage = new Image(display, 1, Math.max(1, rect.height));
           GC gc = new GC(newImage);
           gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
           gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
           gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true);
           gc.dispose();
           styledText.setBackgroundImage(newImage);
           if (oldImage != null) oldImage.dispose();
           oldImage = newImage;
         }
       });
   shell.setSize(700, 400);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   if (oldImage != null) oldImage.dispose();
   font.dispose();
   display.dispose();
 }