Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Swing / AWT / SWT and the fly likes Repaint Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


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

Repaint Issue

Titus Abraham
Ranch Hand

Joined: Jun 03, 2009
Posts: 36
i have a repaint issue where UI doesn't get updated unless i change teh size of the window or minimize , maximize the window

Any ideas ?

scenario: i have a panel class which can set its labels and this panel is being added on to a frame in another class and when we invoke method from panel to set label icons or text it doesn't show on the screen unless i resize of do something which makes it do a repaint..

i tried calling repaint myself but it didn't work. I have no clues what so ever. can some one help me out

Paneldeck( class which extends JPanel)
this has panels and labels
setLabel() is the function which sets the labels


Gamedeck ( class which extends Jframe )
this has panels and one of the subpanel loads the earlier class object

if i call setLabel() in the game deck constructor it works fine

if i call the setLabel() anywhere else it doesnt do its job like how i said initially..

Hoping for an answer.

Best Regards,
titus
Titus Abraham
Ranch Hand

Joined: Jun 03, 2009
Posts: 36
got the answer. updateUi solved the same..
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Titus Abraham wrote:got the answer. updateUi solved the same..


I'm not sure of the exact solution to your problem without seeing code, but I can tell you that your current solution is a bad one. updateUI should most definitely not be used here. I'm guessing that you're adding components after a JFrame has been rendered and that you need to call revalidate and (possibly) then repaint on the container that holds the added components.
W Pearce
Ranch Hand

Joined: Jan 06, 2009
Posts: 32
another solution might be to call the revalidate() method


SCJP 6, SCWCD 5
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
W Pearce wrote:another solution might be to call the revalidate() method

as noted above your post
W Pearce
Ranch Hand

Joined: Jan 06, 2009
Posts: 32
ha yea sorry, apparently skimming isnt as effective as reading
Titus Abraham
Ranch Hand

Joined: Jun 03, 2009
Posts: 36
Thank you.. i am using revalidate now. though i have to check now whats the difference between both.
 
GeeCON Prague 2014
 
subject: Repaint Issue