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

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

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

JComboBox.addFocusListener介绍

暂无

代码示例

代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin

private void initSearch() {
  final List<ImageAsset> imageAssets = new ArrayList<ImageAsset>();
  imageAssets.addAll(materialIconsController.getAssets(materialIconsController.getCategories()));
  for (ImageAsset imageAsset : imageAssets) {
    searchField.addItem(imageAsset);
  }
  searchField.setRenderer(new AssetSpinnerRenderer());
  comboboxSpeedSearch = new ComboboxSpeedSearch(searchField) {
    @Override
    protected String getElementText(Object element) {
      return element instanceof ImageAsset ? ((ImageAsset) element).getName() : "";
    }
  };
  searchField.addFocusListener(new FocusAdapter() {
    @Override
    public void focusGained(FocusEvent e) {
      comboboxSpeedSearch.showPopup();
    }
  });
  searchField.addItemListener(searchFieldListener);
}

代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin

private void initSearch() {
  final List<ImageAsset> imageAssets = new ArrayList<ImageAsset>();
  imageAssets.addAll(androidIconsController.getAssets(androidIconsController.getCategories()));
  imageAssets.addAll(materialIconsController.getAssets(materialIconsController.getCategories()));
  for (ImageAsset imageAsset : imageAssets) {
    searchField.addItem(imageAsset);
  }
  searchField.setRenderer(new AssetSpinnerRenderer());
  comboboxSpeedSearch = new ComboboxSpeedSearch(searchField) {
    @Override
    protected String getElementText(Object element) {
      return element instanceof ImageAsset ? ((ImageAsset) element).getName() : "";
    }
  };
  searchField.addFocusListener(new FocusAdapter() {
    @Override
    public void focusGained(FocusEvent e) {
      comboboxSpeedSearch.showPopup();
    }
  });
  searchField.addItemListener(searchFieldListener);
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

/** Overridden to block the UI from adding its own focus listener, which
 * will close the popup at the wrong times.  We will manage focus
 * ourselves instead */
@Override
public void addFocusListener(FocusListener fl) {
  if (!inSetUI || !tableUI) {
    super.addFocusListener(fl);
  }
}

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

/** Overridden to block the UI from adding its own focus listener, which
 * will close the popup at the wrong times.  We will manage focus 
 * ourselves instead */
public void addFocusListener(FocusListener fl) {
  if (!inSetUI || !tableUI) {
    super.addFocusListener(fl);
  }
}

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

/** Overridden to block the UI from adding its own focus listener, which
 * will close the popup at the wrong times.  We will manage focus 
 * ourselves instead */
public void addFocusListener(FocusListener fl) {
  if (!inSetUI || !tableUI) {
    super.addFocusListener(fl);
  }
}

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

protected void createCombobox() {
  $objectMap.put("combobox", combobox = new JComboBox());
  
  combobox.setName("combobox");
  combobox.addFocusListener(JAXXUtil.getEventListener(FocusListener.class, "focusGained", this, "doFocusGained__on__combobox"));
}

代码示例来源:origin: senbox-org/snap-desktop

private void createCellDefaultValueComboBox(FocusListener focusListener) {
  this.cellDefaultValueComboBox = new JComboBox();
  this.cellDefaultValueComboBox.setOpaque(true);
  this.cellDefaultValueComboBox.setVisible(false);
  this.cellDefaultValueComboBox.setBorder(new EmptyBorder(0, 0, 0, 0));
  this.cellDefaultValueComboBox.addFocusListener(focusListener);
}

代码示例来源:origin: BaseXdb/basex

@Override
public synchronized void addFocusListener(final FocusListener l) {
 final BaseXTextField tf = textField();
 if(tf != null) tf.addFocusListener(l);
 else super.addFocusListener(l);
}

代码示例来源:origin: org.basex/basex

@Override
public synchronized void addFocusListener(final FocusListener l) {
 final BaseXTextField tf = textField();
 if(tf != null) tf.addFocusListener(l);
 else super.addFocusListener(l);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-propertyeditors

borderPaddingCombo.addFocusListener(new java.awt.event.FocusAdapter() {
  public void focusLost(java.awt.event.FocusEvent evt) {
    borderPaddingComboFocusLost(evt);
borderPaddingUnitCombo.addFocusListener(new java.awt.event.FocusAdapter() {
  public void focusLost(java.awt.event.FocusEvent evt) {
    borderPaddingUnitComboFocusLost(evt);

代码示例来源:origin: org.tentackle/tentackle-swing

@Override
protected void installListeners() {
 super.installListeners();
 if (((TentackleLookAndFeel)UIManager.getLookAndFeel()).isFocusAnimated()) {
  comboBox.addFocusListener(new KComboBoxFlasherListener());
 }
}

代码示例来源:origin: senbox-org/snap-desktop

private void createCellDataTypesComponent() {
  this.cellDataTypesComboBox = new JComboBox(typesMap.keySet().toArray());
  this.cellDataTypesComboBox.setOpaque(true);
  this.cellDataTypesComboBox.setVisible(false);
  this.cellDataTypesComboBox.setBorder(new EmptyBorder(0, 0, 0, 0));
  this.cellDataTypesComboBox.addActionListener(ev -> {
    String typeName = (String) cellDataTypesComboBox.getSelectedItem();
    cellDataTypeChanged(typeName, this.cellComponentRowIndex, this.cellComponentColumnIndex);
  });
  this.cellDataTypesComboBox.addFocusListener(new FocusAdapter() {
    @Override
    public void focusLost(FocusEvent focusEvent) {
      hideCurrentDisplayedCellComponent();
    }
  });
}

代码示例来源:origin: tflobbe/solrmeter

@Override
protected Component getVisualComponent() {
  comboBox = new JComboBox();
  for(String value:values) {
    comboBox.addItem(value);
  }
  if(SolrMeterConfiguration.getProperty(property) != null && !"".equals(SolrMeterConfiguration.getProperty(property))) {
    this.setSelectedValue(SolrMeterConfiguration.getProperty(property));
  }
  comboBox.addFocusListener(this);
  comboBox.setEditable(this.isComboEditable());
  comboBox.addActionListener(new ActionListener() {
    
    @Override
    public void actionPerformed(ActionEvent arg0) {
      notifyObservers();
    }
  });
  return comboBox;
}

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

private void initController() {
  RootSelectionHandler rootHandler = new RootSelectionHandler();
  queryRoot.addActionListener(rootHandler);
  queryRoot.addFocusListener(rootHandler);
  queryRoot.getEditor().getEditorComponent().addFocusListener(rootHandler);
  distinct.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      QueryDescriptor query = getQuery();
      if (query != null) {
        query.setProperty(SelectQuery.DISTINCT_PROPERTY, Boolean.toString(distinct.isSelected()));
        mediator.fireQueryEvent(new QueryEvent(this, query));
      }
    }
  });
}

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

searchCombo.addFocusListener(scl);
searchCombo.addKeyListener(scl);
searchPanel.add(searchCombo);

代码示例来源:origin: net.sf.nimrod/nimrod-laf

protected  void installListeners() {
 super.installListeners();
 miML = new MiML();
 comboBox.addMouseListener( miML);
 comboBox.addFocusListener( miML);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

private JComboBox createComboBox( String[] choices, String defaultValue, Icon[] icons, Font font, FocusListener listener ) {
  JComboBox combo = new JComboBox(choices);
  combo.setSelectedItem(defaultValue);
  combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
  combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
  combo.setOpaque(false);
  combo.setFont( font );
  combo.addFocusListener( listener );
  combo.setEnabled( choices.length > 1 );
  combo.setRenderer( new DelegatingRenderer(combo.getRenderer(), choices, icons ) );
  InputMap inputMap = combo.getInputMap( JComboBox.WHEN_FOCUSED );
  inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, 0), "showPopup" ); //NOI18N
  combo.getActionMap().put( "showPopup", new TogglePopupAction() ); //NOI18N
  return combo;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

private JComboBox createComboBox(DataItem item, Font font, FocusListener listener) {
  List<ItemVariant> variants = item.getVariants();
  JComboBox combo = new JComboBox(variants.toArray());
  combo.setSelectedItem(item.getDefaultVariant());
  combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
  combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
  combo.setOpaque(false);
  combo.setFont(font);
  combo.addFocusListener(listener);
  combo.setEnabled(variants.size() > 1);
  combo.setRenderer(new DelegatingRenderer(combo.getRenderer(), variants, item.getVariantIcons()));
  InputMap inputMap = combo.getInputMap(JComboBox.WHEN_FOCUSED);
  inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "showPopup"); //NOI18N
  combo.getActionMap().put("showPopup", new TogglePopupAction()); //NOI18N
  return combo;
}

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

protected void installListeners() {
  super.installListeners();
  if (popup instanceof BasicComboPopup) {
    popupHandler = new PopupHandler();
    ((BasicComboPopup) popup).addPopupMenuListener(popupHandler);
    comboBox.addFocusListener(focusHandler = new FocusHandler());
  }
}

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

/**
 * Enables auto-completion for specified combobox
 *
 * @param comboBox Combo to be featured
 * @param strict Whether strict matching (check 'startWith' or 'contains') should be used
 * @param allowsUserValues Whether non-present items are allowed 
 */
public static void enable(JComboBox comboBox, boolean strict, boolean allowsUserValues) {
  comboBox.setEditable(true);
  KeyListener[] listeners = comboBox.getEditor().getEditorComponent().getListeners(KeyListener.class);
  comboBox.setEditor(new CustomTypeComboBoxEditor(comboBox, allowsUserValues));
  for (KeyListener listener : listeners) {
    comboBox.getEditor().getEditorComponent().addKeyListener(listener);
  }
  AutoCompletion ac = new AutoCompletion(comboBox, strict, allowsUserValues);
  comboBox.addFocusListener(ac);
  ac.textEditor.addKeyListener(ac);
  //original keys would not work properly
  SwingUtilities.replaceUIActionMap(comboBox, null);
}

相关文章

JComboBox类方法