主要代码:
setTitle("滚动美化");
setSize(800, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container container = getContentPane();
container.setLayout(null);
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
DefaultTreeModel model = new DefaultTreeModel(root);
for (int i = 0; i < 200; i++)
{
root.add(new DefaultMutableTreeNode("node_node_node_node_node_" + i));
}
JTree jTree = new JTree(model);
JScrollPane jScrollPane = new JScrollPane(jTree);
jScrollPane.setBounds(10, 10, 200, 200);
jScrollPane.getVerticalScrollBar().setUI(new ScrollBarUIEx
(JScrollBar.VERTICAL));
jScrollPane.getHorizontalScrollBar().setUI(new ScrollBarUIEx
(JScrollBar.HORIZONTAL));
container.add(jScrollPane);
setVisible(true);
2022-08-23 18:21:46
86KB
java
1