How do you get some things to show up on screen when one an event occurs and another thing to show up if something else occurs? I have not put all the logic in place for the following code because I can't get this first one to compile with just one if statement. All the classes that return the data to this screen work fine now (thanks to everyone!). And, I continue to learn lots from this forum (thanks even more for that). I have a class that connects to a DB. Next, I have a class that queries the DB for the info I am looking for. That returns a vector object which is instantiated in another class which creates a panel with a combo box in the panel (the combo box's data comes from the query class). Now I want to have this final class display that panel, (the PatientAdd panel) if the "Add Patient" button is pressed.
The way that I tried to do that was to create my action listener and then put some flow control in that listener. If Add Patient is pressed, then the panel is created and placed on the frame. If some other button is pressed, then some other panel will show up and so on. How do I go about doing this? Right now I am told that I can not use a non-static method (add) in a static context. How does one go about making screens dynamically present other screens on the same frame and am I even close in what I have tried to do here?
"WorkScreen.add()" is trying to call the add() method as if it were a static method -- which it's not, of course. All the methods of the enclosing class are available in an inner class, so you can actually just say (for example) "add()" instead of "WorkScreen.add()"!
Sometimes, there may be an ambiguity between an inner class method and an enclosing class method. The way to deal with this is to say "WorkSpace.this.add()" -- which refers directly to the enclosing object.
There's one more piece of magic voodoo you need: when you make a change to the layout of a container that's actually visible on screen, as here, you need to call validate() on the container which tells the LayoutManager to fix things up.