FULL PRODUCT VERSION :
Mustang b91
A DESCRIPTION OF THE PROBLEM :
JTree is invisible with combination of Right-to-Left component orientation and GTK LaF.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run. You don't see the JTree. Notice that with commented out "scroll.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);" it works ok. It works ok as well with the uncommented "ComponentOrientation.RIGHT_TO_LEFT" code but with another LaF, say Motif.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JTree displays.
ACTUAL -
JTree does not display.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.lang.reflect.InvocationTargetException;
public class GTKTreeRTLTest {
private static JFrame mainFrame;
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
SwingUtilities.invokeAndWait(new Runnable(){
public void run() {
mainFrame = new JFrame("GTKTreeRTLTest");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
// ???
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(mainFrame);
} catch (Exception e) {
throw new RuntimeException("Test failed: ", e);
}
JTree tree = new JTree(getDefaultTreeModel());
tree.setShowsRootHandles(true);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
JPanel mainPanel = new JPanel(new BorderLayout());
JScrollPane scroll = new JScrollPane(tree);
mainPanel.add(scroll, BorderLayout.CENTER);
mainFrame.setContentPane(mainPanel);
// ???
scroll.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
mainFrame.pack();
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
}
});
mainFrame.validate();
}
private static DefaultTreeModel getDefaultTreeModel() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("JTree");
DefaultMutableTreeNode parent;
parent = new DefaultMutableTreeNode("colors");
root.add(parent);
parent.add(new DefaultMutableTreeNode("blue"));
parent.add(new DefaultMutableTreeNode("violet"));
parent.add(new DefaultMutableTreeNode("red"));
parent.add(new DefaultMutableTreeNode("yellow"));
parent = new DefaultMutableTreeNode("sports");
root.add(parent);
parent.add(new DefaultMutableTreeNode("basketball"));
parent.add(new DefaultMutableTreeNode("soccer"));
parent.add(new DefaultMutableTreeNode("football"));
DefaultMutableTreeNode nparent = new DefaultMutableTreeNode("hockey");
parent.add(nparent);
nparent.add(new DefaultMutableTreeNode("ice hockey"));
nparent.add(new DefaultMutableTreeNode("roller hockey"));
nparent.add(new DefaultMutableTreeNode("floor hockey"));
nparent.add(new DefaultMutableTreeNode("road hockey"));
return new DefaultTreeModel(root);
}
}
---------- END SOURCE ----------