This has been bugging me for a while, I'm using a JPanel to render some custom graphics output (a 2D plot) and I want this custom JPanel, or any similarly-designed component, to preview nicely in netbeans. My problem is netbeans seems to only do a very limited initialization and maintenance of components when they are in the layout.

From what I can tell, in design mode the only method that's called is initComponents(), so the constructor doesn't get called which makes it very hard to initialize a component properly so it's not blank in design mode. Using field initializers seems to work and also if I add it to another component that calls the constructor from it's own initComponents() method works too so I'm ok with this, but my problem is that once it's initialized I can't figure out how to get the state updated.

In design mode components are constantly stretched and I want them to react to that. So for instance if I extend a JPanel that paints a border around itself then I want to see that border change to fit the panel as I stretch it in design view. Does anyone know whether netbeans/matisse emits any events or provides any other way to have components draw themselves properly when designing forms? I'd really like to know, this isn't just a cosmetic issue, especially with complex layouts it really matters whether you can get some idea of what a component is going to look like when it runs.

Thank you, any help appreciated greatly.