Aug 012014

Beans binding makes life so much easier when designing GUIs with the NetBeans IDE. It is well integrated into the GUI builder, and usually it just works out of the box.

Last week I developed a new options panel for a NetBeans Platform Application. Creating the framework for the new panel took maybe a minute using the file wizard that sets up everything for you to link the panel to the Options infrastructure of the Platform. I added a text field or two, and bound their text properties to a bean that I had created for this purpose. When I ran the application, I saw that the binding didn’t do anything at all!

So I dived into the source code of the beansbinding library. I debugged through lots and lots of source code – first in a plain old Java application where the binding did work as expected, and then in the platform application that was giving me trouble. I spent maybe an hour and a half deep down in the depths of that library. And then suddenly I found the source of my problem! If you look carefully at the source code in the NetBeans Options Window Module Tutorial, and knew what you were looking for, this like would jump out at you:

The cause of my trouble is that this panel class is NOT public! In retrospect, this makes a lot of sense. Beans binding does a lot of operations via reflection, and if the class is not public the library won’t have access to it!

Tip of the month
For beans binding to work with any GUI panel, that panel must be public!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">