Invalid Thread Access Error with Java SWT

It is thrown because your listener code is called from outside the SWT Display thread. You run code on the display thread like this: Display.getDefault().syncExec(new Runnable() { public void run() { // … } }); or, asynchronously: Display.getDefault().asyncExec(new Runnable() { public void run() { // … } });

Create cross platform Java SWT Application

I’ve just run into the same problem. I haven’t tried it yet, but I plan to include versions of swt.jar for all platforms and load the correct one dynamically in the start of the main method. UPDATE: It worked. build.xml includes all jars: <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_linux_gtk_x86.jar”/> <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_macosx_x86.jar”/> <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_win32_x86.jar”/> <zipfileset dir=”/home/aromanov/workspace/foo/lib” includes=”swt_linux_gtk_x64.jar”/> … Read more

SWT on Windows 64-bit

On 64-bit JVM’s you need the 64-bit SWT. Current versions can be downloaded here: http://archive.eclipse.org/eclipse/downloads/drops/R-3.6.1-201009090800/index.php#SWT Note the first two downloads, the first is for x32, the other for x64. Note: Even on 64bit Windows, if you use the 32bit JVM, you still need the 32bit SWT version!

Setting Colors in SWT

For standard colors (including common colors and default colors used by the operating system) Use Display.getSystemColor(int), and pass in the SWT.COLOR_* constant for the color you want. Display display = Display.getCurrent(); Color blue = display.getSystemColor(SWT.COLOR_BLUE); Color listBackground = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); Note that you do not need to dispose these colors because SWT created them.

Java Desktop application: SWT vs. Swing [closed]

Pros Swing: part of java library, no need for additional native libraries works the same way on all platforms Integrated GUI Editor in Netbeans and Eclipse good online tutorials by Sun/Oracle Supported by official java extensions (like java OpenGL) Cons Swing: Native look and feel may behave different from the real native system. heavy components … Read more

tech