JScrollPane () { if (myTable instanceof TreeTable) { TreeUtil.expandAll(((TreeTable)myTable).getTree()); } JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); if (myTable.getSelectedRow() == -1) { myTable.getSelectionModel().setSelectionInterval(0, 0); } if (myTable.getRowCount() >= 20) { scrollPane.getViewport().setPreferredSize(new Dimension(myTable.getPreferredScrollableViewportSize().width, 300)); } else { scrollPane.getViewport().setPreferredSize(myTable.getPreferredSize()); } if (myBuilder.isAutoselectOnMouseMove()) { myTable.addMouseMotionListener(new MouseMotionAdapter() { boolean myIsEngaged = false; @Override public void mouseMoved(MouseEvent e) { if (myIsEngaged) { int index = myTable.rowAtPoint(e.getPoint()); myTable.getSelectionModel().setSelectionInterval(index, index); } else { myIsEngaged = true; } } }); } return scrollPane; }