Display List of images using ScrollingImagePanel

Posted on 2006-05-01
Last Modified: 2010-08-05
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);
        panel.setBounds(50, 300, 500, 300);
Question by:MuhammadAdil
    LVL 92

    Expert Comment

    how are you changing the image being displayed?
    try (re)validating/repainting the panel after changing the image.
    LVL 3

    Expert Comment

    try inserting a


    within the loop

    LVL 12

    Expert Comment

    I see the same bounds:
    500, 300

    Try to use different, the scroll bars will appears.

    Bye, Giant.

    Accepted Solution


    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.


    Expert Comment

    Thank you for the points, I hope you are solved the problem

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Title # Comments Views Activity
    fix34  challenge 9 70
    squareUp  challenge 22 80
    wordcount challenge 11 45
    Modeling a class in java 5 22
    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now