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

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

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

JTextComponent.isEditable介绍

暂无

代码示例

代码示例来源: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: RipMeApp/ripme

boolean editable = textComponent.isEditable();
boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));
boolean marked = textComponent.getSelectedText() != null;

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

boolean editable = textComponent.isEditable();
boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals(""));
boolean marked = textComponent.getSelectedText() != null;

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

/**
 * This is the type of transfer actions supported by the source.  Some
 * models are not mutable, so a transfer operation of COPY only should
 * be advertised in that case.
 *
 * @param c  The component holding the data to be transfered.  This
 *  argument is provided to enable sharing of TransferHandlers by
 *  multiple components.
 * @return If the text component is editable, COPY_OR_MOVE is returned,
 *         otherwise just COPY is allowed.
 */
@Override
public int getSourceActions(JComponent c) {
  if (((JTextComponent)c).isEditable()) {
    return COPY_OR_MOVE;
  }
  else {
    return COPY;
  }
}

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

final int dot = field.getCaret().getDot();
final int mark = field.getCaret().getMark();
if ( field.isEnabled() && field.isEditable() ) {
 SwingUtilities.invokeLater( new Runnable() {
  @Override

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

@Override
public boolean isEnabled() {
  JTextComponent tc = getTextComponent(null);
  return (tc==null || tc.isEditable()) ? super.isEnabled() : false;
}

代码示例来源: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: ron190/jsql-injection

@Override
public void actionPerformed(ActionEvent e) {
  JTextComponent target = this.getTextComponent(e);
  if (Objects.nonNull(target) && target.isEditable()) {
    Caret caret = target.getCaret();
    int dot  = caret.getDot();
    int mark = caret.getMark();
    if (DefaultEditorKit.deletePrevCharAction.equals(this.getValue(Action.NAME))) {
      // @see javax/swing/text/DefaultEditorKit.java DeletePrevCharAction
      if (dot == 0 && mark == 0) {
        return;
      }
    } else {
      // @see javax/swing/text/DefaultEditorKit.java DeleteNextCharAction
      Document doc = target.getDocument();
      if (dot == mark && doc.getLength() == dot) {
        return;
      }
    }
  }
  this.deleteAction.actionPerformed(e);
}

代码示例来源:origin: ron190/jsql-injection

JTextComponent target = this.getTextComponent(e);
if ((target != null) && (target.isEditable())) {
  try {
    Document doc = target.getDocument();

代码示例来源:origin: ron190/jsql-injection

public void actionPerformed(ActionEvent e) {
  JTextComponent target = this.getTextComponent(e);
  if ((target != null) && (target.isEditable())) {
    try {
      Document doc = target.getDocument();

代码示例来源:origin: ron190/jsql-injection

/**
 * Create popup menu for this component.
 * @param component The component receiving the menu
 */
public JPopupMenuText(JTextComponent component) {
  super(component);
  if (component.isEditable()) {
    JMenuItem cutItem = new JMenuItem();
    cutItem.setIcon(HelperUi.ICON_EMPTY);
    cutItem.setAction(component.getActionMap().get(DefaultEditorKit.cutAction));
    cutItem.setText("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    cutItem.setMnemonic('t');
    JMenuItem pasteItem = new JMenuItem();
    pasteItem.setIcon(HelperUi.ICON_EMPTY);
    pasteItem.setAction(component.getActionMap().get(DefaultEditorKit.pasteAction));
    pasteItem.setText("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
    pasteItem.setMnemonic('P');
    // Before Copy menu
    this.add(cutItem, 0);
    // After Copy menu
    this.add(pasteItem, 2);
  }
}

代码示例来源:origin: com.google.code.validationframework/validationframework-swing

/**
 * @see AbstractComponentProperty#getPropertyValueFromComponent()
 */
@Override
protected Boolean getPropertyValueFromComponent() {
  return component.isEditable();
}

代码示例来源:origin: net.sf.doolin/doolin-gui

@Override
public void focusLost(FocusEvent e) {
  if (text.isEditable()) {
    String s = text.getText();
    setProperty(view, s);
  }
}

代码示例来源:origin: com.threerings/nenya

/**
 * Returns true if the specified target component supports being typed into, and thus we
 * shouldn't steal focus away from it if the user starts typing.
 */
protected boolean isTypeableTarget (Component target)
{
  return target.isShowing() &&
    (((target instanceof JTextComponent) && ((JTextComponent) target).isEditable()) ||
     (target instanceof JComboBox) ||
     (target instanceof JTable) ||
     (target instanceof JRootPane));
}

代码示例来源: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: com.jidesoft/jide-oss

@Override
protected boolean isActivateKey(KeyEvent e) {
  if (_component instanceof JTextComponent && ((JTextComponent) _component).isEditable()) {
    return (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_F && JideSwingUtilities.isMenuShortcutKeyDown(e));
  }
  else {
    return super.isActivateKey(e);
  }
}

代码示例来源:origin: freeplane/freeplane

public static boolean isEditingText() {
  final Component focusOwner = FocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  final boolean isTextComponentFocused = focusOwner instanceof JEditorPane;
  return isTextComponentFocused && focusOwner.isShowing() && ((JTextComponent)focusOwner).isEditable();
}

代码示例来源: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: de.sciss/scisslib

public final void actionPerformed( ActionEvent e )
{
  if( !ignoreFocus ) {
    final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if( (c != null) && (c instanceof JTextComponent) && ((JTextComponent) c).isEditable() ) return;
  }
  validActionPerformed( e );
}

相关文章

JTextComponent类方法