Question

I am designing some custom graphical components using Netbeans 7.4. I am making some smaller components that combine to make larger custom components. However, when I change one of the bottom-level components, the changes do not propagate up to other elements.

Is there any way to insert a custom component so that changes to it's base percolate to all the instances? Somewhat new to fiddling with Swing, so my apologies if this is a trivial thing.

I have already added them to a custom palette hoping that would do something, but alas to no avail.

Was it helpful?

Solution

The NetBeans GUI designer doesn't support this directly, but you can instantiate your own custom components as often as desired. The key is designing for reuse. I try to follow the Swing separable model architecture, even if there's no need for a custom look & feel.

Edit: I added two instances of NewJPanel to Main like in this example. When I changed the label's text in the designer, it changed in both panels at runtime.

f.setLayout(new GridLayout(0, 1));
f.add(new NewJPanel());
f.add(new NewJPanel());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top