本文整理匯總了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"));
}