I have an Eclipse RCP (SWT) Plugin Project and have a view part that has an SWT_AWT Frame with a JTree/JScrollPane/Etc using the following code:
@PostConstruct
public void postConstruct(Composite parent) {
parent.setLayout(new FillLayout(SWT.HORIZONTAL));
Composite comp = new Composite(parent, SWT.EMBEDDED);
comp.setLayout(new FillLayout(SWT.HORIZONTAL));
Frame frame = SWT_AWT.new_Frame(comp);
try {
UIManager
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
}
JPanel panel = new JPanel(new BorderLayout());
frame.add(panel);
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
for (int i = 0; i < 100; i++) {
DefaultMutableTreeNode obj = new DefaultMutableTreeNode("Test " + i);
root.add(obj);
for (int f = 0; f < 100; f++) {
obj.add(new DefaultMutableTreeNode("Test " + i));
}
}
JTree fileTable = new JTree(root);
fileTable.setRootVisible(false);
JScrollPane scrollPane = new JScrollPane(fileTable);
scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
panel.add(scrollPane);
frame.add(scrollPane);
}
When I add the code for double buffering; I have it set explicitly on the ScrollBars of the JScrollPanel to see if I could fix the problem.
scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
I had it set on the scroll panel before this; but either way both things result in the same problem.
The issue goes away though when you move the mouse over it; it works as expected. When I switch to other parts (tabs) and go back to this tab, the issue presents itself again. The issue also goes away when I do not set double buffering, but this results in a horrible flickering of the scroll bars.
Anyone have any ideas?