本文整理汇总了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();
}
示例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();
}
});
}
示例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"));
}
示例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;
}
示例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);
}
示例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);
}
示例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"));
}