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

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

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

JTextComponent.isFocusOwner介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch

private void textChanged () {
  if (command.isFocusOwner()) {
    displayer.maybeEvaluate(command.getText());
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch

/** implementation of ActionListener, called by timer,
 * actually runs search */
@Override
public void actionPerformed(ActionEvent e) {
  updateTimer.stop();
  // search only if we are not cancelled already
  if (comboBar.getCommand().isFocusOwner()) {
    evaluatorRP.post(new Runnable() {
      @Override
      public void run() {
        if (evalTask != null) {
          evalTask.removeTaskListener(QuickSearchPopup.this);
        }
        evalTask = CommandEvaluator.evaluate(searchedText, rModel);
        evalTask.addTaskListener(QuickSearchPopup.this);
        // start waiting on all providers execution
        RP.post(evalTask);
      }
    });
  }
}

代码示例来源:origin: otros-systems/otroslogviewer

@Override
public void focusLost(FocusEvent e) {
 Component oppositeComponent = e.getOppositeComponent();
 boolean focusOwner = textComponent.isFocusOwner();
 if (!focusOwner && !(oppositeComponent != null && oppositeComponent.getParent() == suggestionPanel)) {
  hideSuggestions();
 }
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
 * Sets the {@link FocusBehavior} on <code>textComponent</code> and
 * repaints the component to reflect the changes, if it is the focus owner.
 * 
 * @param focusBehavior
 * @param textComponent
 */
public static void setFocusBehavior(FocusBehavior focusBehavior, JTextComponent textComponent) {
  textComponent.putClientProperty(FOCUS_BEHAVIOR, focusBehavior);
  if (textComponent.isFocusOwner()) {
    textComponent.repaint();
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * Sets the {@link FocusBehavior} on <code>textComponent</code> and
 * repaints the component to reflect the changes, if it is the focus owner.
 * 
 * @param focusBehavior
 * @param textComponent
 */
public static void setFocusBehavior(FocusBehavior focusBehavior, JTextComponent textComponent) {
  textComponent.putClientProperty(FOCUS_BEHAVIOR, focusBehavior);
  if (textComponent.isFocusOwner()) {
    textComponent.repaint();
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Sets the {@link FocusBehavior} on <code>textComponent</code> and
 * repaints the component to reflect the changes, if it is the focus owner.
 * 
 * @param focusBehavior
 * @param textComponent
 */
public static void setFocusBehavior(FocusBehavior focusBehavior, JTextComponent textComponent) {
  textComponent.putClientProperty(FOCUS_BEHAVIOR, focusBehavior);
  if (textComponent.isFocusOwner()) {
    textComponent.repaint();
  }
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
 * Sets the {@link FocusBehavior} on <code>textComponent</code> and
 * repaints the component to reflect the changes, if it is the focus owner.
 * 
 * @param focusBehavior
 * @param textComponent
 */
public static void setFocusBehavior(FocusBehavior focusBehavior, JTextComponent textComponent) {
  textComponent.putClientProperty(FOCUS_BEHAVIOR, focusBehavior);
  if (textComponent.isFocusOwner()) {
    textComponent.repaint();
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch

/** ActionListener implementation, reaction to popup menu item invocation */
public void actionPerformed(ActionEvent e) {
  JRadioButtonMenuItem item = (JRadioButtonMenuItem)e.getSource();
  CommandEvaluator.setEvalCat((Category) item.getClientProperty(CATEGORY));
  CommandEvaluator.setCatTemporary(false);
  // refresh hint
  setShowHint(!command.isFocusOwner());
}

代码示例来源:origin: net.java.truecommons/truecommons-key-swing

private void updateEditor(final ComboBoxEditor cbe, final @Nullable Object item) {
  if (lock()) return;
  try {
    cbe.setItem(item);
    if (!(item instanceof String)) return;
    final JComboBox<E> cb = getComboBox();
    final JTextComponent tc = (JTextComponent) cbe.getEditorComponent();
    assert cb.isShowing() || !tc.isFocusOwner();
    if (!tc.isFocusOwner() /* || !cb.isShowing() */) return;
    // Compensate for an issue with some look and feels
    // which select the entire tc if an item is changed.
    // This is inconvenient for auto completion because the
    // next typed character would replace the entire tc...
    final Caret caret = tc.getCaret();
    caret.setDot(((String) item).length());
  } finally {
    unlock();
  }
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-swing

private void updateEditor(final ComboBoxEditor cbe, final @CheckForNull Object item) {
  if (lock())
    return;
  try {
    cbe.setItem(item);
    if (!(item instanceof String))
      return;
    final JComboBox<E> cb = getComboBox();
    final JTextComponent tc = (JTextComponent) cbe.getEditorComponent();
    assert cb.isShowing() || !tc.isFocusOwner();
    if (!tc.isFocusOwner() /* || !cb.isShowing() */)
      return;
    // Compensate for an issue with some look and feels
    // which select the entire tc if an item is changed.
    // This is inconvenient for auto completion because the
    // next typed character would replace the entire tc...
    final Caret caret = tc.getCaret();
    caret.setDot(((String) item).length());
  } finally {
    unlock();
  }
}

代码示例来源:origin: net.java.truevfs/truevfs-key-swing

private void updateEditor(final ComboBoxEditor cbe, final @CheckForNull Object item) {
  if (lock())
    return;
  try {
    cbe.setItem(item);
    if (!(item instanceof String))
      return;
    final JComboBox<E> cb = getComboBox();
    final JTextComponent tc = (JTextComponent) cbe.getEditorComponent();
    assert cb.isShowing() || !tc.isFocusOwner();
    if (!tc.isFocusOwner() /* || !cb.isShowing() */)
      return;
    // Compensate for an issue with some look and feels
    // which select the entire tc if an item is changed.
    // This is inconvenient for auto completion because the
    // next typed character would replace the entire tc...
    final Caret caret = tc.getCaret();
    caret.setDot(((String) item).length());
  } finally {
    unlock();
  }
}

代码示例来源:origin: net.java.truecommons/truecommons-key-swing

private void documentUpdated() {
  if (lock()) return;
  try {
    final JComboBox<E> cb = getComboBox();
    final ComboBoxEditor cbe = cb.getEditor();
    final JTextComponent tc = (JTextComponent) cbe.getEditorComponent();
    assert cb.isShowing() || !tc.isFocusOwner();
    if (!tc.isFocusOwner() /* || !cb.isShowing() */) return;
    //cb.setPopupVisible(update(tc.getText())); // doesn't work: adjusts popup size!
    cb.setPopupVisible(false);
    if (update(tc.getText())) cb.setPopupVisible(true);
  } finally {
    unlock();
  }
}

代码示例来源:origin: net.java.truevfs/truevfs-key-swing

private void documentUpdated() {
  if (lock())
    return;
  try {
    final JComboBox<E> cb = getComboBox();
    final ComboBoxEditor cbe = cb.getEditor();
    final JTextComponent tc = (JTextComponent) cbe.getEditorComponent();
    assert cb.isShowing() || !tc.isFocusOwner();
    if (!tc.isFocusOwner() /* || !cb.isShowing() */)
      return;
    //cb.setPopupVisible(update(tc.getText())); // doesn't work: adjusts popup size!
    cb.setPopupVisible(false);
    if (update(tc.getText()))
      cb.setPopupVisible(true);
  } finally {
    unlock();
  }
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-swing

private void documentUpdated() {
  if (lock())
    return;
  try {
    final JComboBox<E> cb = getComboBox();
    final ComboBoxEditor cbe = cb.getEditor();
    final JTextComponent tc = (JTextComponent) cbe.getEditorComponent();
    assert cb.isShowing() || !tc.isFocusOwner();
    if (!tc.isFocusOwner() /* || !cb.isShowing() */)
      return;
    //cb.setPopupVisible(update(tc.getText())); // doesn't work: adjusts popup size!
    cb.setPopupVisible(false);
    if (update(tc.getText()))
      cb.setPopupVisible(true);
  } finally {
    unlock();
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch

if ((modelSize > 0 || statusVisible) && comboBar.getCommand().isFocusOwner()) {
  if (modelSize > 0 && !isVisible()) {
    jList1.setSelectedIndex(0);

代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch

public void performAction() {
  if (comboBar == null) {
    comboBar = isAqua
          ? new AquaQuickSearchComboBar((KeyStroke) this.getValue(Action.ACCELERATOR_KEY))
          : new QuickSearchComboBar((KeyStroke) this.getValue(Action.ACCELERATOR_KEY));
  }
  comboBar.displayer.explicitlyInvoked();
  if (comboBar.getCommand().isFocusOwner()) {
    // repetitive action invocation, reset search to all categories
    comboBar.evaluateCategory(null, false);
  } else {
    comboBar.requestFocus();
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

promptComponent = createPromptComponent();
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIDE_PROMPT) {
  promptComponent.setText(null);
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

promptComponent = createPromptComponent();
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIDE_PROMPT) {
  promptComponent.setText(null);
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());

代码示例来源:origin: org.swinglabs.swingx/swingx-all

promptComponent = createPromptComponent();
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIDE_PROMPT) {
  promptComponent.setText(null);
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

promptComponent = createPromptComponent();
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIDE_PROMPT) {
  promptComponent.setText(null);
if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());

相关文章

JTextComponent类方法