i have been reading this book called Begining Java2 by Ivor Horton - Wrox publication. in the chapter for event handling the author says
because events are processed in a separate thread from the main thread, you
must not modify or query the GUI for an application from the main thread once the GUI has been displayed
or is ready to be displayed. Otherwise, a deadlock may result.
What does this mean ?
Further in the immideate next section "Avioding Deadlocks in GUI " after a few lines the author says
As I
said in the previous section, once an application GUI has been realized, modifying or querying it on the
main thread can cause deadlock because user interactions with the GUI, such as clicking a menu item,
are handled in the event-dispatching thread. There is also the rare possibility with some types of Swing
components that deadlocks can occur even when it is not apparent that you are modifying the GUI after
it has been realized. You can avoid any possibility of deadlock in your application arising from your GUI
creation code by arranging to execute all the code that creates the GUI on the event-dispatching thread.
I havent very much followed what the suthor is trying to say. I understand that he means to say that we cant change or modify the GUI one it has been displayed (rendered) but what is the problem with that ? Does that mean that we cant remove or add a component from within the actionPerformed() method corresponding to the component from the same window . Can anyone please throw some light on this fact