In my application i am using the same window and change the components at various button events using remove(),revalidate() and repaint().
in this code i am i have three different methods
2. actionPerformed() in SubmitHandler class (inner class to SCJPTestApplication class)
3. actionPerformed() in BeginTest class (inner class to SCJPTestApplication class)
the initialWindow () method displays the initial window which asks the user to select and submit the chapter from which he/she expects the test. On clicking the submit button on the initial window the actionPerformed method in the SubmitHandler listener class is invoked which removes the current components, revalidates, adds new components (a button called "Begin Test" and a label showing the chapter name selected for the test). DURING THE RUN THE PROGRAM WORKS PERFECTCLY TILL THIS POINT.
Clicking the "Begin Test" button calls the actionPerformed() in the BeginTest class which removes the current components, adds new ones (a non-editable JTextpane holding the current question, few radiobuttons for options, and the submit button) and repaints the JPanel holding the components. The problem is that the window does not get Repainted. I have put several println() statemnts to check on the console if this actionPerformed method in the BeginTest class is executing. On the console it shows complete execution of the actionPerformed method. but the window is not repainted. I dont know why below given is the code.
i have put various println() statements to check on the console if the action
Yes you are right, why reinvent the wheel, bbut you see hidden within these problem and queries are immense treasures of knowledge i am a newbee for javax.swing and wish to take up the right approach not a quick-fix approach. i just wish to know the reason why ?
Thanks Stanislav, i hv done that also. but the real problem is something else and i have figured it out. I m using the same button object called "submit" and registering with two different ActionListeners. This is the problem. Its more important to find out the mechanics of ActionListeners to know why does this turn into a DeadLock. Good Question
Joined: Dec 01, 2009
Create a fields for both listeners and add/remove appropriate one when necessary.