// ensures that the selection is visible
 // because textcomponent doesn't show selection
 // when they don't have focus
 public void focusGained(FocusEvent e) {
   Caret caret = ((JTextComponent) comp).getCaret();
   caret.setVisible(true);
   caret.setSelectionVisible(true);
 }