Hello All,
I am fairly new to Java and have been perusing the boards here picking up little things here and there and I think I have really been learning a lot. Anyway, I have been following this thread
https://coderanch.com/t/519939/GUI/java/do-you-switch-JPanels-shown and as a result, I learned about the CardLayout Manager and did some experimenting and playing with it which made me wonder about a couple of things.
If you had some menu, maybe JMenuBar or JToolBar, in a JFrame and some of the menu items' actions were to change the content of the JFrame, maybe from one form to another or one picture to another, something like that, Would CardLayout Manager be something appropriate to use for this or would you replace the contents of the JFrame with a new JPanel each time the individual actions are called? From reading the API for CardLayout, it would be best to use it with mulitple Panels, all uniquely named and then call a change to that name with the individual actions of the JMenuItems.
Now, that said brings me to my next curiousity. I recently read up on Threads and Concurrency in Swing and the use of the invokeLater method to send everything to the event dispatching thread. Should calls to change the card be done in a similar way? I have found most of the Swing components say Thread safe or not, but CardLayout does not, although it says it is Serializable which would indicate to me (not sure about this one) that the cahnges should be called through invokeLater.
Sorry about all the questions, just trying to straighten out in my head what I learned and read over the last couple of days.
Thanks for your time,
Mike