Weird Behaviour of JScrollPane.getPreferredSize() when using SCROLLBAR_AS_NEEDED
I am trying to use the height returned by JScrollPane.getPreferredSize() such that the custom layout manager I wrote for its parent could set the size of the scroll pane properly. However the behaviour of that function is pretty weird when using VERTICAL_SCROLLBAR_AS_NEEDED and HORIZONTAL_SCROLLBAR_AS_NEEDED, to the point I am almost wondering if it is a bug in jdk 220.127.116.11p4. Here is what it does:
-When there is no horizontal scroll bar, the height of a horizontal scroll bar IS included in getPreferredSize().height
-When there is a horizontal scroll bar, the height of the scroll bar is NOT included in getPreferredSize().height
So to me it looks like getPreferredSize() is doing the opposite it should be doing. Am I missing something?