JAVA - how to modify SWT UI while looping in thread
JAVA - how to modify SWT UI while looping in thread I'm trying to implement a Desktop app that loops trough a function and sets a textfield on the UI every 1 sec. But I either get org.eclipse.swt.SWTException: Invalid thread access when I don't use the display or the UI is really sluggish when I do display.asyncExec(new Runnable() { My code looks like this: public void open() { Display display = Display.getDefault(); shell = new Shell(); shell.setSize(486, 322); shell.setText("SWT Application"); Button btnStartLoop = new Button(shell, SWT.NONE); btnStartLoop.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() // updates displayArea { while (true) { try { text.setText("Text has been set"); ...