TextViewer: setDocument(IDocument idoc)
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MainClass extends ApplicationWindow {
public MainClass() {
super(null);
}
public void run() {
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
}
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("Text Editor");
shell.setSize(600, 400);
}
protected Control createContents(Composite parent) {
TextViewer viewer = new TextViewer(parent, SWT.NONE);
viewer.setDocument(new Document());
return viewer.getTextWidget();
}
public static void main(String[] args) {
new MainClass().run();
}
}
Related examples in the same category