Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Flickering Component View in JPanel with JScrollPane

 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, i have problem image flickering in JPanel with ScrollPane

I add image from specified folder to display in JPanel with ScrollPane.
And in each image i add actionListener, when the user click the image, it have preview.

When i scroll down the Jpanel, and i try to preview the image, JPanel has flicker.
This is the preview,


How to handle that?




And this my ImageViewer (JFrame)



Please help me.
Thanks before.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48985
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried double buffering? You set that by passing true to one of the overloaded constructors of (I think) the JPanel class.
 
Fandy Akhmad
Ranch Hand
Posts: 32
Java Linux MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Have you tried double buffering? You set that by passing true to one of the overloaded constructors of (I think) the JPanel class.


Hello, i am new to hear double buffering. Do you have any reference?
Thank you, ^^
 
Campbell Ritchie
Sheriff
Pie
Posts: 48985
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not many. Try the constructor, and this Wikipedia article.
 
Rob Camick
Ranch Hand
Posts: 2584
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Double buffering is turned on automatically in Swing so there is nothing for you to do.

I don't really understand your application. It looks like you are trying to display a popup JFrame with the image. You should be using a JDialog as a child window. You should not be setting the size/location of the image panel. Let the layout managers do this for you.

Unless you post a SSCCE I have no more advice to offer.
 
Rob Camick
Ranch Hand
Posts: 2584
9
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic