Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Repaint Issue

 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got the answer. updateUi solved the same..
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another solution might be to call the revalidate() method
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
W Pearce wrote:another solution might be to call the revalidate() method

as noted above your post
 
W Pearce
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ha yea sorry, apparently skimming isnt as effective as reading
 
Titus Abraham
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.. i am using revalidate now. though i have to check now whats the difference between both.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic