@ 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 ) ; } }
Required by TreeSelectionListener interface .