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 http://www.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.
You don't need to call invokeLater from the EDT itself, except a few cases (like requesting focus). Changing the active panel is not one of them, so from the event handler you can safely change the active panel. From any other thread you'll need invokeLater.
Note that in AWT and Swing, nothing should be considered to be thread safe unless explicitly mentioned to be so (like JTextArea.append).