Code:
Display display = new Display();
RowLayout rowLayout = new RowLayout();
Shell shell = new Shell(display);
shell.setLayout(rowLayout);
Text textArea = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
textArea.setLayoutData(new RowData(200, 200));
shell.open();
while(!shell.isDisposed()) {
if(display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
Problem: Typing in text is dog slow. I literally have to wait 1 – 3 seconds to let the text widget lag behind displaying my text in snail steps. Am i doing something wrong ?
Your
readAndDispatchloop is backwards. The documentation forDisplay#readAndDispatch()states that it:Thus, your loop should actually be:
My understanding of
sleep()was that it should be fairly efficient about waking up when there’s a new event to service, but that’s certainly not a guarantee.