JScrollPane doesn't scroll far enough

I'm having trouble with a JScrollPane that doesn't quite scroll to the bottom. The situation is that I have images that are each displayed by a JPanel. They are added to a main JPanel (flowlayout) that is added to the JScrollPane. So what you get is a bunch of images (think thumbnail preview images) displayed in a pane that only scrolls vertically. The problem comes when the last row of images contains an image that is taller than the rest (like one potrait layout with the rest in landscape layout). When the user scrolls down the last part of the taller images is cutoff and the scrollbar doesn't go any further.

Has anyone seen something like this?

[671 byte] By [mburns_javaa] at [2007-11-27 10:18:10]
# 1

> Has anyone seen something like this?

No.

> They are added to a main JPanel (flowlayout) that is added to the JScrollPane

When you add components to a FlowLayout they flow horizontally, not vertically so I don't know how you are getting multiple rows of images. You must have some custom code. Since we don't know what this custom code is we don't know what you are doing wrong.

One solution would be to use a JList. Read the API and follow the link to the tutorial on "How to Use List" which has an example of how you can use a JList to do horizontal wrapping.

If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",

see http://homepage1.nifty.com/algafield/sscce.html,

that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.

Don't forget to use the "Code Formatting Tags",

see http://forum.java.sun.com/help.jspa?sec=formatting,

so the posted code retains its original formatting.

camickra at 2007-7-28 15:55:55 > top of Java-index,Desktop,Core GUI APIs...