I'm working on a little app that has several Product classes, and a sort of "manager" class. Each product class has a range of GUI panels, eg "Add New Product Panel", and "Edit Product Panel".
What I want to do is call these panels from the "manager" class - so for example, if the user clicks the "edit product" button, the edit product panel is opened up in the main content pane.
I'm having a bit of a battle with it - I want to keep the panels in their corresponding classes, but it seems that doing it that way, my only option is to make each panel a method, so I can call that method from the manager class. That leasds to a host of problems which I won't go into, but I'd appreciate any ideas on a better way to do it.
Thanks for the help - I've kind of got it working with the method way, but I think I might try your other idea - I guess the question is which is more elegant / professional?
One other question - as I said I have it kind of working so far, but I've noticed a small problem. Each of the panels has a borderlayout, and the center panel of each panel is made up of a gridbag layout. When I run the app, I can switch between panels about 3 times before the center panel seems to revert to a flow layout. I'm using repaint() and validate() every time I switch panels, but for some reaon after about 3 switches it stops working.
I'm sure this is a problem with my code, but I've noticed a couple of similar problems when using GridBagLayout before - any ideas would be appreciated :)
Yes, I'm removing the panels, but I'm using the removeAll() method - I've heard people say that you should really remove all the individual panels instead of using this blanket method, but I can't do that without knowing what the existing panel is.
So it looks like Card Layout might be the one. Thanks again.
Yes, I've got similar code now, though I didn't have it when I first posted. I think the problem must be my components or something - I'll get there eventually :)