Code example for JTextComponent

Methods: getText

0
 
  public void update(AnActionEvent e) {
    final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext());
    if (component instanceof JTextComponent) {
      final JTextComponent textComponent = (JTextComponent)component;
      e.getPresentation().setEnabled(textComponent.getText().length() > 0 && ((JTextComponent)component).isEditable());
    } 
    else { 
      e.getPresentation().setEnabled(false);
    } 
  } 
}