Mixed version java JTable
-
You can find the JVM version in the "java.version" system property.
-
Copy the source of the JTable sorter object to your project and use it. Note that you are not allowed to redistribute this unless you have a license from Sun. So it's okay for something that you only use yourself or within your company. Selling it or putting it online for download is not okay. IANAL .
-
Write a helper class that implements the sorter interface. In this class, enter this code:
Sorterclass = Class.forName ("javax.swing.table.TableRowSorter");
The class is not available when this throws a ClassNotFoundException. If so, use Reflection on sorterClass
to instantiate and set it to the table.
Note. You don't have to import any of the Java 6 classes anywhere! If you do this, the loading of the helper class will fail. Also, you have to compile your code with Java 5.
source to share