JColorchooser avec une chaleur et une sensation, Java 7
Question
J'écris une application qui utilise la substance look et sentez-vous avec un jcolorchooser.Cela fonctionne bien avec Java 6, mais en essayant des choses avec Java 7, ce n'est vraiment pas JColorchooser:
java.lang.NullPointerException
at org.pushingpixels.substance.internal.ui.SubstanceListUI$SubstanceListSelectionListener$1.run(SubstanceListUI.java:135)
Je suppose que cela consiste à faire avec le nouveau JColorchooser qui est introduit dans Java 7, et que la substance est liée à celle actuelle d'une manière ou d'une autre.Toutefois, en dehors de l'écriture de mon propre sélecteur de couleurs, est-ce un bon chemin autour de ce problème que quelqu'un sait?Je suppose que la substance (espoir) sera mise à jour en temps voulu pour résoudre ce problème, mais j'aimerais jouer avec certaines des nouvelles fonctionnalités des premières constructions de Java 7 avant sa publication.
Je soupçonne en quelque sorte que la réponse est non, mais s'il y a une solution / patch rapide quelque part (je ne pouvais pas en trouver un), ce serait utile!
La solution
This is an interesting study in "Bug Compatibility." If the color is set to null and you try and get the color from the color chooser, a NullPointerException resulted. Kirill expected this and trapped it in a try/catch block. However, in Java 7 they instead return null from that method instead of throwing an NPE.
There are about three snippets of code that need to be changed:
https://github.com/Insubstantial/insubstantial/commit/0f01ae676c6f56d6879862a911ad03caeafabc52
In the next week or so I'm going to publish my first distribution of insubstantial that will include this fix.