GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes container Repaint problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "container Repaint problem" Watch "container Repaint problem" New topic
Author

container Repaint problem

shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
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

1. initialWindow()
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
>
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Why reinvent the wheel?
Check out CardLayout


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
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 ?
Stanislav Lapitsky
Ranch Hand

Joined: Dec 01, 2009
Posts: 53


Regards,
Stas
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
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
Stanislav Lapitsky
Ranch Hand

Joined: Dec 01, 2009
Posts: 53
Create a fields for both listeners and add/remove appropriate one when necessary.

Regards,
Stas
 
GeeCON Prague 2014
 
subject: container Repaint problem