當前位置: 首頁>>代碼示例>>Java>>正文


Java ComboBox.addItemListener方法代碼示例

本文整理匯總了Java中com.intellij.openapi.ui.ComboBox.addItemListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ComboBox.addItemListener方法的具體用法?Java ComboBox.addItemListener怎麽用?Java ComboBox.addItemListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.ui.ComboBox的用法示例。


在下文中一共展示了ComboBox.addItemListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCustomPanel

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
@Nullable
@Override
protected JComponent createCustomPanel() {
  myProjectLabel = new JBLabel("Project:", SwingConstants.RIGHT);
  myProjectCombobox = new ComboBox(200);
  myProjectCombobox.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(final ItemEvent e) {
      updateFilters();
    }
  });
  installListener(myProjectCombobox);
  myFilterLabel = new JBLabel("Filter:", SwingConstants.RIGHT);
  myFilterCombobox = new ComboBox(200);
  installListener(myFilterCombobox);
  updateProjects();
  return FormBuilder.createFormBuilder().addLabeledComponent(myProjectLabel, myProjectCombobox)
    .addLabeledComponent(myFilterLabel, myFilterCombobox).getPanel();
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:20,代碼來源:MantisRepositoryEditor.java

示例2: initCommonViews

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
private void initCommonViews() {
    test_type = new ComboBox(new String[]{"Espresso", "Junit"});
    test_type.setBorder(null);
    test_type.addItemListener(e -> {
        if (test_type.getSelectedIndex() == 0) {
            testSelector = new TestSelectorEspresso(tests_panel, search_field, project);
            populate();
        } else {
            testSelector = new TestSelectorJUnit(tests_panel, search_field, project);
            populate();
        }
    });
}
 
開發者ID:amng,項目名稱:TestSelector,代碼行數:14,代碼來源:Main.java

示例3: NodeJSModuleExtensionPanel

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
@RequiredDispatchThread
public NodeJSModuleExtensionPanel(final NodeJSMutableModuleExtension extension, Runnable runnable)
{
	super(new VerticalFlowLayout(true, false));

	add(ModuleExtensionSdkBoxBuilder.createAndDefine(extension, runnable).build());

	List<JavaScriptLanguageVersion> validLanguageVersions = StandardJavaScriptVersions.getInstance().getValidLanguageVersions();

	ComboBox languageVersionComboBox = new ComboBox(new CollectionComboBoxModel(validLanguageVersions, extension.getLanguageVersion()));
	languageVersionComboBox.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent e)
		{
			if(e.getStateChange() == ItemEvent.SELECTED)
			{
				//noinspection unchecked
				extension.setLanguageVersion((LanguageVersion) e.getItem());
			}
		}
	});
	languageVersionComboBox.setRenderer(new ColoredListCellRenderer<BaseJavaScriptLanguageVersion>()
	{
		@Override
		protected void customizeCellRenderer(JList list, BaseJavaScriptLanguageVersion value, int index, boolean selected, boolean hasFocus)
		{
			append(value.getPresentableName());
		}
	});

	add(LabeledComponent.create(languageVersionComboBox, "Language Version"));
}
 
開發者ID:consulo,項目名稱:consulo-nodejs,代碼行數:34,代碼來源:NodeJSModuleExtensionPanel.java

示例4: createComboBox

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
/**
 * Creates a Combo Box of String items.
 */
public static ComboBox createComboBox(JComponent parent,
                                      ItemListener listener, String[] items, int defaultSelection) {
    ComboBox comboBox = new ComboBox(items);
    comboBox.setSelectedIndex(defaultSelection);
    comboBox.addItemListener(listener);
    parent.add(comboBox);
    return comboBox;
}
 
開發者ID:TestRoots,項目名稱:watchdog,代碼行數:12,代碼來源:UIUtils.java

示例5: initCombo

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
void initCombo(final ComboBox combobox, final JPanel parentPanel) {
    combobox.setModel(new DefaultComboBoxModel(JsonDataType.values()));
    combobox.setRenderer(new ColoredListCellRenderer() {

        @Override
        protected void customizeCellRenderer(JList jList, Object o, int i, boolean b, boolean b2) {
            append(((JsonDataType) o).type);
        }
    });

    combobox.setSelectedItem(null);
    combobox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            JsonDataType selectedType = (JsonDataType) combobox.getSelectedItem();
            currentEditor = UI_COMPONENT_BY_JSON_DATATYPE.get(selectedType);
            currentEditor.reset();

            parentPanel.invalidate();
            parentPanel.removeAll();
            parentPanel.add(currentEditor.getComponent(), BorderLayout.CENTER);
            parentPanel.validate();
        }
    });

    combobox.setSelectedItem(JsonDataType.STRING);
}
 
開發者ID:dboissier,項目名稱:nosql4idea,代碼行數:29,代碼來源:AbstractAddDialog.java

示例6: ChangeListChooser

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
public ChangeListChooser() {
  super(new BorderLayout(4, 2));
  myChooser = new ComboBox();
  //noinspection unchecked
  myChooser.setRenderer(new ColoredListCellRendererWrapper<LocalChangeList>() {
    @Override
    protected void doCustomize(JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        String name = StringUtil.shortenTextWithEllipsis(value.getName().trim(), MAX_LEN, 0);

        append(name, value.isDefault() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });

  myChooser.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        final LocalChangeList changeList = (LocalChangeList)myChooser.getSelectedItem();
        setSelectedList(changeList);
        myChooser.setToolTipText(changeList == null ? "" : (changeList.getName()));
      }
    }
  });

  myChooser.setEditable(false);
  add(myChooser, BorderLayout.CENTER);

  JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label"));
  label.setLabelFor(myChooser);
  add(label, BorderLayout.WEST);
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:33,代碼來源:MultipleChangeListBrowser.java

示例7: ClientJavaScriptModuleExtensionPanel

import com.intellij.openapi.ui.ComboBox; //導入方法依賴的package包/類
public ClientJavaScriptModuleExtensionPanel(final JavaScriptMutableModuleExtension<?> extension)
{
	super(new VerticalFlowLayout(true, false));

	List<JavaScriptLanguageVersion> validLanguageVersions = StandardJavaScriptVersions.getInstance().getValidLanguageVersions();

	ComboBox languageVersionComboBox = new ComboBox(new CollectionComboBoxModel(validLanguageVersions, extension.getLanguageVersion()));
	languageVersionComboBox.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent e)
		{
			if(e.getStateChange() == ItemEvent.SELECTED)
			{
				//noinspection unchecked
				extension.setLanguageVersion((LanguageVersion) e.getItem());
			}
		}
	});
	languageVersionComboBox.setRenderer(new ColoredListCellRenderer<BaseJavaScriptLanguageVersion>()
	{
		@Override
		protected void customizeCellRenderer(@NotNull JList list, BaseJavaScriptLanguageVersion value, int index, boolean selected, boolean hasFocus)
		{
			append(value.getPresentableName());
		}
	});

	add(LabeledComponent.left(languageVersionComboBox, "Language Version"));
}
 
開發者ID:consulo,項目名稱:consulo-javascript,代碼行數:31,代碼來源:ClientJavaScriptModuleExtensionPanel.java


注:本文中的com.intellij.openapi.ui.ComboBox.addItemListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。