question: private void openPopupMenu ( MouseEvent e ) { if ( ! e . isPopupTrigger ( ) ) { return ; } if ( popupMenu == null ) { return ; } final int index = tabs . indexAtLocation ( e . getX ( ) , e . getY ( ) ) ; if ( tabs . getSelectedIndex ( ) == index ) { popupMenu . show ( tabs , e . getX ( ) , e . getY ( ) ) ; } }
target:  Open context menu manually instead of relying on the JTabbedPane, so we can check if it's the currently selected tab (since the context menu will trigger actions based on the currently selected tab).