• Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel Borders  RSS feed

 
simon keillor
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Have an application where we I have numerous labels displayed on a JLayeredPane. Some of these labels are just coloured squares, others display images.

I want to display which label is currently selected by adding a border. This works fine on the coloured squares but if I add a border to a JLabel which is displaying an image, the image is being constantly refreshed and flickers. I can't seem to stop it happening.

Does anyone have any ideas as to why this is happeneing?

Any help greatly appreciated.

Thanks

Simon
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing how you are adding the border and where in your code it's hard to say. Guessing I'd say that you are adding the border on every single repaint of the screen for some reason which is not needed and because of that and drawing the image you could get some flicker. But again, this is just guessing without seeing how you are doing it.
 
simon keillor
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,

You were right, I moved setBorder from paintComponent and I have no more flickering now.

Thank you very much for your help.



Simon
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!