In many examples, this template is used to launch the Swing application. You might want to try it. The whole goal is to create Swing components inside the Swing Thread.
public static void main(String[] args) {
EDIT: After carefully studying the issue. You cannot run Swing on the Android / Dalvik platform. As other people commented, it works fine, if it works on the Sun JVM, it looks like you are using it under an Android emulator. This will not work.
Update tags to enable Android if you are trying to run it on Android.
source share