javax.swing.JComboBox.isShowing()方法的使用及代码示例

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

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

JComboBox.isShowing介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

private static void setListStrings() {
  Object findObject = FIND_FIELD.getSelectedItem();
  Object replaceObject = REPLACE_FIELD.isShowing() ?
      (String) REPLACE_FIELD.getSelectedItem() : "";
  if (findObject != null && replaceObject != null) {
    boolean found = false;
    for (int i = 0; !found && i < FIND_FIELD.getItemCount(); i++) {
      found = FIND_FIELD.getItemAt(i).equals(findObject);
    }
    if (!found) {
      FIND_FIELD.insertItemAt(findObject, 0);
      if (FIND_FIELD.getItemCount() > 7) {
        FIND_FIELD.removeItemAt(7);
      }
    }
    if (REPLACE_FIELD.isShowing()) {
      found = false;
      for (int i = 0; !found && i < REPLACE_FIELD.getItemCount(); i++) {
        found = REPLACE_FIELD.getItemAt(i).equals(findObject);
      }
      if (!found) {
        REPLACE_FIELD.insertItemAt(replaceObject, 0);
        if (REPLACE_FIELD.getItemCount() > 7) {
          REPLACE_FIELD.removeItemAt(7);
        }
      }
    }
  }
}

代码示例来源:origin: aterai/java-swing-tips

@Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
  if (combo.isShowing() && (infoflags & (FRAMEBITS | ALLBITS)) != 0) {
   repaintComboBox(combo, row);
  }
  return (infoflags & (ALLBITS | ABORT)) == 0;
 }
});

代码示例来源:origin: org.gosu-lang.gosu/gosu-editor

public void run()
 {
  if( _comboSearch.isShowing() )
  {
   _comboSearch.requestFocus();
  }
 }
} );

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

public void keyReleased(KeyEvent e) {
  if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER) {
    String text = textEditor.getText();
    if (comboBox.isShowing()) {
      suggestionList.hide();
      suggestionList.filter(text);
      suggestionList.show();
    }
  }
}

代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun

private void hidePopup() {
  if (combobox.isShowing() && combobox.isPopupVisible()) {
    combobox.setPopupVisible(false);
  }
}

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

public void run() {
  String text = textEditor.getText();
  //need to hide first because Swing incorrectly updates popups (getSize() returns
  //dimension not the same as seen on the screen)
  suggestionList.hide();
  if (comboBox.isShowing()) {
    suggestionList.filter(text);
    if (suggestionList.getItemCount() > 0) {
      suggestionList.show();
    }
  }
}

代码示例来源:origin: edu.stanford.protege/ca.uvic.cs.chisel.cajun

private void showPopup() {
  if (isShowPopup() && combobox.isShowing() && combobox.isEnabled() && !combobox.isPopupVisible()) {
    combobox.setPopupVisible(true);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

public void actionPerformed(ActionEvent e)
  {
    JComboBox comboBox= (JComboBox) e.getSource();
    if (comboBox.isEnabled() && comboBox.isShowing())
    {
      if (comboBox.isPopupVisible())
      {
        ComboBoxUI ui= (ComboBoxUI) comboBox.getUI();
        ui.selectNextPossibleValue();
      }
      else
      {
        comboBox.setPopupVisible(true);
      }
    }
  }
}

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets

protected void updateFilter() {
  JComboBox comboBox = ui.getCombobox();
  JaxxFilterableComboBoxModel model = (JaxxFilterableComboBoxModel) comboBox.getModel();
  JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
  // hide the popup before setting the filter, otherwise the popup height does not fit
  boolean wasPopupVisible = comboBox.isShowing() && comboBox.isPopupVisible();
  if (wasPopupVisible) {
    comboBox.hidePopup();
  }
  String text = editorComponent.getText();
  if (ui.getSelectedItem() != null) {
    text = "";
  }
  if (log.isDebugEnabled()) {
    log.debug("updateFilter " + text);
  }
  model.setFilterText(text);
  if (wasPopupVisible) {
    comboBox.showPopup();
  }
}

代码示例来源:origin: joel-costigliola/assertj-swing

/**
 * Returns the {@code String} representation of the given {@code Component}, which should be a {@code JComboBox}.
 *
 * @param c the given {@code Component}.
 * @return the {@code String} representation of the given {@code JComboBox}.
 */
@RunsInCurrentThread
@Override
@Nonnull protected String doFormat(@Nonnull Component c) {
 JComboBox<?> comboBox = (JComboBox<?>) c;
 String format = "%s[name=%s, selectedItem=%s, contents=%s, editable=%b, enabled=%b, visible=%b, showing=%b]";
 return String.format(format, getRealClassName(c), quote(comboBox.getName()),
            quote(comboBox.getSelectedItem()), Arrays.format(contentsOf(comboBox)), comboBox.isEditable(),
            comboBox.isEnabled(), comboBox.isVisible(), comboBox.isShowing());
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java16

/**
 * A small convenience method to try showing the ComboBoxPopup.
 */
private void togglePopup() {
  // break out early if we're flagged to ignore attempts to toggle the popup state
  if (doNotTogglePopup) return;
  if (comboBoxModel.getSize() == 0)
    comboBox.hidePopup();
  else if (comboBox.isShowing() && !comboBox.isPopupVisible() && comboBoxEditorComponent.hasFocus())
    comboBox.showPopup();
}

代码示例来源:origin: com.haulmont.thirdparty/glazedlists

/**
 * A small convenience method to try showing the ComboBoxPopup.
 */
private void togglePopup() {
  // break out early if we're flagged to ignore attempts to toggle the popup state
  if (doNotTogglePopup) return;
  if (comboBoxModel.getSize() == 0) {
    comboBox.hidePopup();
  }
  else if (comboBox.isShowing() && !comboBox.isPopupVisible() && comboBoxEditorComponent.hasFocus())
    comboBox.showPopup();
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java15

/**
 * A small convenience method to try showing the ComboBoxPopup.
 */
private void togglePopup() {
  // break out early if we're flagged to ignore attempts to toggle the popup state
  if (doNotTogglePopup) return;
  if (comboBoxModel.getSize() == 0)
    comboBox.hidePopup();
  else if (comboBox.isShowing() && !comboBox.isPopupVisible() && comboBoxEditorComponent.hasFocus())
    comboBox.showPopup();
}

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets

/**
 * Reset the combo-box; says remove any selected item and filter text.
 */
public void reset() {
  if (ui.getSelectedItem() != null) {
    ui.setSelectedItem(null);
  } else {
    JTextComponent editorComponent = (JTextComponent) ui.getCombobox().getEditor().getEditorComponent();
    editorComponent.setText("");
  }
  JComboBox comboBox = ui.getCombobox();
  if (comboBox.isShowing()) {
    comboBox.hidePopup();
  }
}

代码示例来源: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: 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: 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.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: 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: 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();
  }
}

相关文章

JComboBox类方法