Posts

Showing posts with the label swt

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"); ...

Javac cannot find SWT library despite correct classpath

Javac cannot find SWT library despite correct classpath I have a Java project that uses SWT and compiles/runs perfectly. When I try to compile via Ant, however, javac cannot find the SWT library despite the build.xml specifying the correct classpath. The SWT library is located in C:my_workEclipse3.6-64plugins . As seen below (under the javac tags, this classpath is specified as such. C:my_workEclipse3.6-64plugins javac build.xml <?xml version="1.0" encoding="UTF-8"?> <project default="run" name="My Project"> <target name="run" depends="compile"> <java classname="com.company.program.project"> <classpath path="staging" location="C:my_workEclipse3.6-64plugins"/> </java> </target> <target name="compile"> <javac includeantruntime="false" srcdir="./src" destdir="staging"> <classpath...