aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Flickering Component View in JPanel with JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Flickering Component View in JPanel with JScrollPane" Watch "Flickering Component View in JPanel with JScrollPane" New topic
Author

Flickering Component View in JPanel with JScrollPane

Fandy Akhmad
Ranch Hand

Joined: Nov 26, 2011
Posts: 32

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

Joined: Oct 13, 2005
Posts: 39834
    
  28
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

Joined: Nov 26, 2011
Posts: 32

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

Joined: Oct 13, 2005
Posts: 39834
    
  28
Not many. Try the constructor, and this Wikipedia article.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2215
    
    7
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

Joined: Jun 13, 2009
Posts: 2215
    
    7
Crossposted: flickering-jpanel-with-jscrollpane-when-jdialog-exist

Be Forthright When Cross Posting To Other Sites
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Flickering Component View in JPanel with JScrollPane