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).
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.