javax.swing.text.JTextComponent.isEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中javax.swing.text.JTextComponent.isEnabled()方法的一些代码示例,展示了JTextComponent.isEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.isEnabled()方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:isEnabled

JTextComponent.isEnabled介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

private void process(MouseEvent e) {
    textComponent.requestFocus();

    boolean enabled = textComponent.isEnabled();
    boolean editable = textComponent.isEditable();
    boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));
    boolean marked = textComponent.getSelectedText() != null;
    boolean pasteAvailable = Toolkit.getDefaultToolkit().getSystemClipboard()
        .getContents(null).isDataFlavorSupported(DataFlavor.stringFlavor);

    undoAction.setEnabled(enabled && editable && undoManager.canUndo());
    redoAction.setEnabled(enabled && editable && undoManager.canRedo());
    cutAction.setEnabled(enabled && editable && marked);
    copyAction.setEnabled(enabled && marked);
    pasteAction.setEnabled(enabled && editable && pasteAvailable);
    deleteAction.setEnabled(enabled && editable && marked);
    selectAllAction.setEnabled(enabled && nonempty);

    int nx = e.getX();
    if (nx > 500) {
      nx = nx - popup.getSize().width;
    }
    popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
  }
}

代码示例来源:origin: wiztools/rest-client

private void eEnable() {
  if(se_req_body.getEditorComponent().isEnabled()) {
    Component[] components = bpm.getComponents();
    for(Component c: components) {
      if(!c.isEnabled()) {
        c.setEnabled(true);
      }
    }
  }
}

代码示例来源:origin: RipMeApp/ripme

textComponent.requestFocus();
boolean enabled = textComponent.isEnabled();
boolean editable = textComponent.isEditable();
boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));

代码示例来源:origin: stackoverflow.com

textComponent.requestFocus();
boolean enabled = textComponent.isEnabled();
boolean editable = textComponent.isEditable();
boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * This method indicates if a component would accept an import of the
 * given set of data flavors prior to actually attempting to import it.
 *
 * @param comp The component to receive the transfer.  This argument is
 *        provided to enable sharing of TransferHandlers by multiple
 *        components.
 * @param flavors The data formats available.
 * @return <code>true</code> iff the data can be inserted.
 */
@Override
public boolean canImport(JComponent comp, DataFlavor[] flavors) {
  JTextComponent c = (JTextComponent)comp;
  if (!(c.isEditable() && c.isEnabled())) {
    return false;
  }
  return (getImportFlavor(flavors, c) != null);
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

/**
 * Overridden to also focus the text component on right mouse clicks.
 *
 * @param e The mouse event.
 */
@Override
public void mousePressed(MouseEvent e) {
  super.mousePressed(e);
  if (!e.isConsumed() && SwingUtilities.isRightMouseButton(e)) {
    JTextComponent c = getComponent();
    if (c!=null && c.isEnabled() && c.isRequestFocusEnabled()) {
      c.requestFocusInWindow();
    }
  }
}

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

@Override
  public boolean isEnabled() {
    return jcomp.isEnabled() && (jcomp.getDocument().getLength() > 0);
  }
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public boolean isEnabled() {
    if (comp.isEditable() && comp.isEnabled()) {
      Transferable contents = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this);
      return contents.isDataFlavorSupported(DataFlavor.stringFlavor);
    } else {
      return false;
    }
  }
}

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

@Override
  public boolean isEnabled() {
    if (jcomp.isEditable() && jcomp.isEnabled()) {
      Transferable contents = Toolkit.getDefaultToolkit()
          .getSystemClipboard().getContents(this);
      return contents.isDataFlavorSupported(DataFlavor.stringFlavor);
    } else
      return false;
  }
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public boolean isEnabled() {
    return comp.isEditable()
        && comp.isEnabled()
        && comp.getSelectedText() != null;
  }
}

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

@Override
  public boolean isEnabled() {
    return jcomp.isEditable() && jcomp.isEnabled()
        && (jcomp.getSelectedText() != null);
  }
}

代码示例来源:origin: gaborbata/jpass

@Override
  public boolean isEnabled(JTextComponent component) {
    return component != null && component.isEnabled() && component.isEditable()
        && component.getSelectedText() != null;
  }
}),

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public boolean isEnabled() {
    return comp.isEditable()
        && comp.isEnabled()
        && comp.getSelectedText() != null;
  }
}

代码示例来源:origin: net.java.abeille/abeille

public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
      if (!target.isEditable() || !target.isEnabled()) {
        target.getToolkit().beep();
        return;
      }
      target.replaceSelection(text);
    }
  }
}

代码示例来源:origin: net.java.abeille/abeille

public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
      if (!target.isEditable() || !target.isEnabled()) {
        target.getToolkit().beep();
        return;
      }
      target.cut();
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void actionPerformed(ActionEvent evt, JTextComponent target) {
    if (target != null) {
      if (!target.isEditable() || !target.isEnabled()) {
        target.getToolkit().beep();
        return;
      }
      target.replaceSelection(text);
    }
  }
}

代码示例来源:origin: SKCraft/Launcher

@Override
public void show(Component invoker, int x, int y) {
  JTextComponent textComponent = (JTextComponent) invoker;
  boolean editable = textComponent.isEditable() && textComponent.isEnabled();
  cutItem.setVisible(editable);
  pasteItem.setVisible(editable);
  deleteItem.setVisible(editable);
  super.show(invoker, x, y);
}

代码示例来源:origin: atarw/material-ui-swing

private void installMyDefaults() {
  this.activeBackground = UIManager.getColor("TextField.selectionBackground");
  this.activeForeground = UIManager.getColor("TextField.selectionForeground");
  this.inactiveBackground = UIManager.getColor("TextField.inactiveBackground");
  this.inactiveForeground = UIManager.getColor("TextField.inactiveForeground");
  getComponent().setFont(MaterialFonts.REGULAR);
  getComponent().setSelectionColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeBackground : inactiveBackground);
  getComponent().setSelectedTextColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
  getComponent().setForeground(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
  getComponent().setBorder(BorderFactory.createEmptyBorder(3, 5, 2,5));
}
@Override

代码示例来源:origin: com.jidesoft/jide-oss

/**
 * This method will call {@link #showHints(boolean)} if and only if the text component is enabled and has focus.
 *
 * @param autoPopup
 */
protected void showHintsPopup(boolean autoPopup) {
  if (!getTextComponent().isEnabled() || !getTextComponent().isEditable() || !getTextComponent().hasFocus()) {
    return;
  }
  showHints(autoPopup);
}

代码示例来源:origin: com.jtattoo/JTattoo

private void updateBackground() {
    JTextComponent c = getComponent();
    if (c.getBackground() instanceof UIResource) {
      if (!c.isEnabled() || !c.isEditable()) {
        c.setBackground(AbstractLookAndFeel.getDisabledBackgroundColor());
      } else {
        c.setBackground(AbstractLookAndFeel.getInputBackgroundColor());
      }
    }
  }
}

相关文章

JTextComponent类方法