• Post Reply Bookmark Topic Watch Topic
  • New Topic

Blinking of components when using repaint()

 
Murali Jaya Rao
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have used some components like JRadioButton and JTree. I have also used paintComponent() of JPanel and created those components in this method.When i give repaint() and updateUI() the components in the UI are blinking. How to overcome from this problem.

Thanks
Murali.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Murali Jaya Rao:
..and created those components in this method.


Why are you doing it inside the paint method? That is the wrong way to do it. What other stuff are you doing it in paint?

Usually you should :
1)Have a method to initialize all the components you need to add on the panel
2)Have a second method which will layout these components on the panel.
These two methods can be called sequentially from the panel constructor.

The paint method should be used only if you want to do some custom painting stuff for the panel.
[ September 26, 2008: Message edited by: Maneesh Godbole ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Why are you doing it inside the paint method?

explained here

http://forums.sun.com/thread.jspa?threadID=5334806&tstart=0
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!