import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class MeasureString {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
GC gc = new GC(shell);
Point size = gc.textExtent("Hellooooooooooooooooooooo");
System.out.println("Hello -> " + size);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
|