Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SWT repaint problem  RSS feed

 
jan dressen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a strange problem in SWT:

when I dispose some widgets and place new widgets on a composite then the newly created widget is not visible. an example is attached in the screenshot on the left side of the picture.
BUT: at the moment I resize my screen, suddenly the control pops-up. as you can see on the right side of the screen.

any idea why this happens, and how i can fix it?
greenshot_2010-01-04_16-51-47.jpg
[Thumbnail for greenshot_2010-01-04_16-51-47.jpg]
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Swing you need to call repaint() and/or revalidate() after you change the component hierarchy. It wouldn't surprise me if the was necessary in SWT.
 
jan dressen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried calling redraw and update, but that doesn't fix it. repaint/revalidate is not available in SWT

but thanks anyway
 
jan dressen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution myself. It seems you have to call the layout(true, true) method on the composite containing your control. that makes it repaint its children
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I knew it was something similar, I just didn't know the SWT equivalent.
 
jan dressen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for pointing me in the correct direction...
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!