• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Display List of images using ScrollingImagePanel

Hi, following method is called by clicking Next image Button
problem is that he is displaying first image with scrollbar, but second image display without scroll bar and same as third and so on.  
 public void displayImage2(PlanarImage ri)
    {
       
        panel = new ScrollingImagePanel(ri,500, 300);
        getContentPane().add(panel);
        panel.setBounds(50, 300, 500, 300);
    }
0
MuhammadAdil
Asked:
MuhammadAdil
1 Solution
 
objectsCommented:
how are you changing the image being displayed?
try (re)validating/repainting the panel after changing the image.
0
 
arun_kuttzCommented:
try inserting a

getContentPane().repaint();

within the loop

-KuTtZ
0
 
Giant2Commented:
I see the same bounds:
500, 300

Try to use different, the scroll bars will appears.

Bye, Giant.
0
 
GyftusCommented:
Hello,

I once had the same problem, it is with revalidating the jComponent after the image has changed.

Question are you overriding paintComponent to add the Image? Are you using a JLabel to set the Image?

These two have very different implications, could you please tell me exactly what ImageScrollingPanel is a subclass of and how the image is being added.

The problem definately lies with the revalidation, revalidate(), and the overriding of the size methods of a JComonent. The ViewPort needs to define its size,
it gets 0,0 before being displayed and that is why the scroll bars dont apear. After it is displayed it has a width and height.

0
 
GyftusCommented:
Thank you for the points, I hope you are solved the problem
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now