Hola
Puedes intentar con
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
Aqui un ejemplo...
import javax.swing.*;
import java.awt.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
public class jtree extends JFrame {
private JPanel panel;
private JScrollPane scroll;
private JTree tree;
private DefaultMutableTreeNode root;
private DefaultMutableTreeNode nodo1;
private DefaultMutableTreeNode nodo2;
private DefaultTreeModel model;
public static void main(String args[]) {
new jtree().setVisible(true);
}
public jtree() {
iniciarComponentes();
}
private void iniciarComponentes() {
panel = new JPanel();
scroll = new JScrollPane();
root = new DefaultMutableTreeNode("Raiz");
nodo1 = new DefaultMutableTreeNode("nodo1");
nodo2 = new DefaultMutableTreeNode("nodo2");
model = new DefaultTreeModel(root);
tree = new JTree(model);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle("Prueba JTree");
setResizable(false);
getContentPane().setLayout(new FlowLayout());
panel.setPreferredSize(new Dimension(200, 300));
panel.setLayout(null);
root.add(nodo1);
root.add(nodo2);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scroll.setViewportView(tree);
panel.add(scroll);
scroll.setBounds(10, 10, 180, 280);
getContentPane().add(panel);
pack();
}
}
Espero te sirva
Saludos