A Simple GUI Program with multiple JPanels

Suppose we want to make a program that produces the following silly GUI:

You see that we have three copies of what is essentially the same strip of components: a label and a combo-box. It'd be nice to view this strip of components as a brand new GUI component, and a nice way to do that is to make it a new derived class of JPanel. That way all we need to do is instantiate it three time. The whole point of this little example is to show you how simple that is!



Important! Notice how the "rewriter" code is completely separated from the GUI code. It is an operator that makes sense on its own, can be developed and tested on its own, and might be useful in other contexts. We do not want that code to be tied up in GUI-specific stuff!