code: @Override
      public void valueChanged(TreeSelectionEvent e) {
          DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
  
          if (node != null && node.isLeaf()) {
              int pos = workspace.getDividerLocation();
              workspace.setTopComponent((JPanel) node.getUserObject());
              workspace.setDividerLocation(pos);
          }
      }
docs: Required by TreeSelectionListener interface.