Use Image as a caret : Caret « SWT « Java Tutorial






Use Image as a caret
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Caret;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class CaretImage {

  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.open();

    Caret caret = new Caret(shell, SWT.NONE);
    Image image = new Image(display, "yourFile.gif");
    caret.setLocation(10, 10);
    caret.setImage(image);
    caret.setVisible(true);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }

    display.dispose();
  }
}








17.76.Caret
17.76.1.Add Caret to Shell (window)Add Caret to Shell (window)
17.76.2.Use Image as a caretUse Image as a caret