怎样消除JTree在展开和合闭时的闪烁?(付代码)
package test;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.tree.*;
public class Applet1 extends Applet {
public void init(){
try{
DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
DefaultMutableTreeNode one = new DefaultMutableTreeNode("one");
DefaultMutableTreeNode two = new DefaultMutableTreeNode("two");
DefaultMutableTreeNode three = new DefaultMutableTreeNode("three");
one.add(new DefaultMutableTreeNode("1"));
one.add(new DefaultMutableTreeNode("2"));
one.add(new DefaultMutableTreeNode("3"));
one.add(new DefaultMutableTreeNode("4"));
one.add(new DefaultMutableTreeNode("5"));
one.add(new DefaultMutableTreeNode("6"));
one.add(new DefaultMutableTreeNode("7"));
root.add(one);
root.add(two);
root.add(three);
root.add(new DefaultMutableTreeNode("4"));
root.add(new DefaultMutableTreeNode("5"));
root.add(new DefaultMutableTreeNode("6"));
root.add(new DefaultMutableTreeNode("7"));
root.add(new DefaultMutableTreeNode("8"));
root.add(new DefaultMutableTreeNode("9"));
two.add(new DefaultMutableTreeNode("4"));
two.add(new DefaultMutableTreeNode("5"));
two.add(new DefaultMutableTreeNode("6"));
two.add(new DefaultMutableTreeNode("7"));
two.add(new DefaultMutableTreeNode("8"));
two.add(new DefaultMutableTreeNode("9"));
this.add(new JScrollPane().add(new JTree(new DefaultTreeModel(root))));
}
catch(Exception e) {
e.printStackTrace();
}
}
}