Metal LAF JScrollPane rendering bug?
Hi all,
Having played around with the JScrollPane class for a couple of days, I've come across a very strange rendering problem regarding the horizontal JScrollBar compnent. When using these components within the default swing "Metal" look-and-feel, the center gripper pattern of the horizontal scrollbar appears to render incorrectly at specific content/viewport dimensions.
The code below opens a simple JFrame window with an embedded JScrollPane component, which appears to exhibit strange rendering behaviour as the horizontal scrollbar is dragged towards the rightmost extemity. As the rendering of the horizontal scrollbar gripper appears to be dependent upon the size of the content/viewport, this code opens the parent JFrame with an explicit dimension of 1402x800. Varying dimensions appear to have the same effect, including a maximized window at a 1440x900 resolution, and the problem tends to present itself more readily in a non-composited desktop environment (i.e. Windows XP or Vista/7 running a basic/classic theme).
Code :
public class Main
{
public static void main(String[] args)
{
ScrollbarTest application = new ScrollbarTest();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
public class ScrollbarTest extends JFrame
{
public ScrollbarTest()
{
super("Scrollbar Test");
Container container = getContentPane();
JScrollPane scrollPane =
new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
JPanel contentPanel = new JPanel();
contentPanel.setPreferredSize(new Dimension(8000, 8000));
scrollPane.getViewport().add(contentPanel);
container.add(scrollPane);
setSize(1402,800);
setVisible(true);
}
}
Any comments regarding the reproducibility and/or cause of this anomaly would be gratefully received.
Best regards, Lee.
Re: Metal LAF JScrollPane rendering bug?
I don't see anything wrong with how this renders (I'm using Windows XP).
Perhaps a screenshot of what's going on would help?
1 Attachment(s)
Re: Metal LAF JScrollPane rendering bug?
Hi Kevin, thanks for the reply.
I've attached an image depicting the anomaly I'm experiencing. As you can see, the center gripper feature is not rendered as I drag the horizontal scrollbar toward its right extremity.
Please note that this doesn't appear to happen at all window sizes, but the initial JFrame dimension of 1402x800 certainly does the trick on my system. To be perfectly honest, this problem was not apparent until I moved from a 1280x800 to 1440x900 screen. :confused:
Again, thanks for taking the time to reply.
Cheers, Lee.