What's the deal with the different Swing package names?
When Swing first came out, Sun wanted to make it available for JDK 1.1.x, but have it be part of the core Java class libraries for the Java 2 platform (then known as JDK 1.2).
The initial thought was that they would have two separate names for Swing:
- com.sun.java.swing for use with JDK 1.1.x
- java.awt.swing for use with the Java 2 platform
For quite some time this seemed to be a settled issue. Developers who wanted to start early development with Swing would use the com.sun.java.swing names, then convert the names to java.awt.swing when they were ready to use the Java 2 platform. The trouble started when a few too many developers wrote Swing code with JDK 1.1.x.
There were so many developers using Swing in JDK 1.1.x that Sun wanted to make the transition easier. So they decided to specify that the com.sun.java.swing packages were considered core classes for the Java 2 platform. This would make conversion to the Java 2 platform easy, as the source could would not need to change.
This raised an uproar among many Java purists. They felt that having the name "sun" in a package name that was core to the Java 2 platform was inappropriate. Heated debates ensued, and Sun decided to change strategies. They decided to pick a name that could be used in both JDK 1.1.x and the Java 2 platform. The name could not start with "java.", so they chose to consider Swing a standard extension to JDK 1.1.x, and named the packages starting with "javax.swing". Note that even though the name says "standard extension", Swing is still considered a core package in the Java 2 platform; it must be delivered with any Java 2 platform implementation.
All current Swing package names start with "javax.swing", regardless of whether you are using JDK 1.1.x or the Java 2 platform. If using JDK 1.1.x, you cannot assume the swing packages are present; they are considered a standard extension. If using the Java 2 platform, you can assume they are present.
RenamingUse the PackageRenamer utility if you need help transitioning from the old names to the new.