Jun 062012
 

Every so often I manage to do something really silly in the GUI builder, which causes unexpected behaviour (and exceptions) when the form is actually executed. And today I realised again that it is indeed sometimes important which step you choose to associate a piece of code with. For example, accidentally trying to set a property on the component in the pre-creation step would fail since the component just doesn’t exist yet at that point.

So the tip I want to share with you today is this. If you encounter a component that does something unexpected (or doesn’t as the case may be), then start off by looking at it using the Code Customizer. It can be accessed by right-clicking on the component and choosing Customize Code…

Code Customizer showing silly error

The Code Customizer is a handy view showing you the source code related only to the current component, in the order in which it will be executed. And if you read through the code in sequence there, many errors will become very obvious indeed. :)

Of course, setting the text as in the above example should rather be done by setting the text property. Then the GUI builder will take care of setting it properly. This is intended just as an example of the type of issue that you could pick up in this way.

For more information about the NetBeans GUI Builder, have a look at the Introduction to GUI Building tutorial.

 Leave a Reply

(required)

(required)


× two = 14

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