private void checkToClearSelection(){
  if (!isFocusOwner() && (lastContextMenu == null || !lastContextMenu.isVisible())) {
    clearSelection();
  }
}

private void checkToClearSelection ( ) { if ( ! isFocusOwner ( ) && ( lastContextMenu == null || ! lastContextMenu . isVisible ( ) ) ) { clearSelection ( ) ; } }
clears the selection if dialog is not active .
