Name: krC82822 Date: 09/24/2000
24 Sep 2000, eval1127@eng -- reproducible on NT 4.0, with 1.3.0-C, with Win L&F (works fine under Metal). Couldn't find existing bug covering this issue.
D:\jb\src>java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Html format labels in JTree with the Windows look and feel vanish when you
click on the lable above. To reproduce, run the attached Java application and
click on the JTree nodes labelled "three", "two", and "one", in that order.
import java.awt.Container;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.UIManager;
/** Check out tree, because we seem to lose labels with the Windows look and
feel */
class SimpleTree
{
private static String block(String s)
{
return "<html>" + s + "</html>";
}
public static void main(String[] s) throws Exception
{
System.err.println("To reproduce, click on the nodes marked three, two, one
in that order");
UIManager.setLookAndFeel
("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
JFrame jf = new JFrame();
DefaultMutableTreeNode top = new DefaultMutableTreeNode(block("top"));
DefaultMutableTreeNode one = new DefaultMutableTreeNode(block("one"));
one.add(new DefaultMutableTreeNode(block("oneChild")));
top.add(one);
DefaultMutableTreeNode two = new DefaultMutableTreeNode(block("two"));
top.add(two);
two.add(new DefaultMutableTreeNode(block("twoChild")));
DefaultMutableTreeNode three = new DefaultMutableTreeNode(block("three"));
three.add(new DefaultMutableTreeNode(block("threeChild")));
top.add(three);
JTree jt = new JTree(top); // same results with "new JTree(new DefaultTreeModel(top))"
Container cp = jf.getContentPane();
cp.add(jt);
jf.pack();
jf.setVisible(true);
}
}
(Review ID: 109724)
======================================================================