Is it possible to port a UI developed using Swing in Java 1.6 to Java 1.5 without rewriting all again?
If you've only used features that are common between the two, I'd say yes. It should be backwards compatible. The moment you add JDK 6 specific features you have to take those out.
Just to elaborate on what duffymo said:
Java is designed to be backward compatible. I.e. if you write something in 1.5 you can run it in 1.6. Of course there are limits to that (e.g. new reserved words like assert break it) but in general it works fine.
If you go the other way, it's a bit more dangerous. You certainly won't need to rewrite all your code, but you might have used features only available since 1.6. Such features can be new classes or new methods of existing classes.
Another thing is the binary code level. You can set your compiler running 1.6 to create code for 1.5 or even 1.4.
But beware, that your 1.6 compiler most certainly compiles against a 1.6 rt.jar. That means you won't notice missing classes or methods until you actually run or compile your code with 1.5.
Setting the compliance level only means that the 1.5 JRE will understand the code, not that all "default" classes are available.
I don't have any experience with 1.6 specifics, but i think while 1.5 added a lot of new language features (that are not all compatible with 1.4), 1.6 was more of a maintenance release.
Since Swing didn't change much in the last ten years, you should not run into many problems. Java 6 also hasn't many new features over Java 5 (mostly internal cleanup).
I suggest to just try to compile your app with Java 5 and run it. It might work out of the box.
As problem is with group layout, here are some pointers.
Older version of Group layout code is still available at http://swing-layout.dev.java.net/ ... this isn't latest version as found in JDK 6, but maybe it will work for you? (In case you cannot find it, here is link to latest release: https://swing-layout.dev.java.net/servlets/ProjectDocumentList?folderID=8136&expandFolder=8136&folderID=0)
And if you're using NetBeans, here are steps to configure Netbeans to use external group-layout for deploying on jdk5: http://blogs.sun.com/NetBeansSupport/entry/target_jdk
If you want to assure your code runs in a 1.5 environment, set your IDE to to build against the 1.5 JDK, that way you won't inadvertently use any of the new API.