当前位置: 首页>>代码示例>>Java>>正文


Java ItemListener类代码示例

本文整理汇总了Java中java.awt.event.ItemListener的典型用法代码示例。如果您正苦于以下问题:Java ItemListener类的具体用法?Java ItemListener怎么用?Java ItemListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ItemListener类属于java.awt.event包,在下文中一共展示了ItemListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCheckBoxToPanel

import java.awt.event.ItemListener; //导入依赖的package包/类
public void addCheckBoxToPanel(Food food) {
    JFrame frame = this;
    jPanel2.setLayout(new GridLayout(0, 4));
    final JCheckBox box = new JCheckBox(food.getFood());
    box.setActionCommand(String.valueOf(food.getId()));
    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (box.isSelected()) {
                jTextArea1.append(box.getText() + "\n");
                selectedFoodIds.add(Integer.parseInt(box.getActionCommand()));
            }
        }
    });
    jPanel2.add(box);
    frame.revalidate();
    frame.repaint();
}
 
开发者ID:seyidkanan,项目名称:my-diploma-work,代码行数:19,代码来源:IngredientsFrame.java

示例2: getPopupMenuItem

import java.awt.event.ItemListener; //导入依赖的package包/类
public JMenuItem getPopupMenuItem(JTextComponent target) {
    
    item = new JCheckBoxMenuItem(NbBundle.getBundle(BaseKit.class).
            getString("line-numbers-menuitem"), isLineNumbersVisible());
    item.addItemListener( new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ActionFactory.java

示例3: setActivated

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * activates or deactivates the widget in the panel
 * @param activated boolean true to activate and false to deactivate
 */
public void setActivated(boolean activated) {
	if(widget!=null && widget.isClickable()){
		widget.setActive(activated);
		if(activated){
			labelPanel.setBackground(highlightColor);
			jLabel.setForeground(Color.GRAY);
		}else{
			labelPanel.setBackground(Color.GRAY);
			jLabel.setForeground(highlightColor);
		}
		if(widget!=null){
			widget.onActiveChanged();
		}
		//notify the listeners over the widet the state change event
		for(ItemListener listener: listeners){
			ItemEvent e = new ItemEvent(this,0,widget, isActivated() ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
			listener.itemStateChanged(e);
		}
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:25,代码来源:GroupPanel.java

示例4: attachListeners

import java.awt.event.ItemListener; //导入依赖的package包/类
private void attachListeners() {
    localeComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(final ItemEvent e) {
            RP.post(new Runnable() {
                @Override
                public void run() {
                    final Set<File> jars = loadPlatformJars();
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            if (e.getStateChange() == ItemEvent.SELECTED) {
                                branding.refreshLocalizedBundles((Locale) e.getItem());
                                prepareTree(jars);
                            }
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:InternationalizationResourceBundleBrandingPanel.java

示例5: create

import java.awt.event.ItemListener; //导入依赖的package包/类
public static GitCommitPanel create(final File[] roots, final File repository, GitUser user, boolean fromGitView) {
    Preferences preferences = GitModuleConfig.getDefault().getPreferences();
    String lastCanceledCommitMessage = GitModuleConfig.getDefault().getLastCanceledCommitMessage();

    GitCommitParameters parameters = new GitCommitParameters(preferences, lastCanceledCommitMessage, user);
    
    Collection<GitHook> hooks = VCSHooks.getInstance().getHooks(GitHook.class);
    GitHookContext hooksCtx = new GitHookContext(roots, null, new GitHookContext.LogEntry[] {});        
    
    DiffProvider diffProvider = new DiffProvider();
    final GitCommitTable gitCommitTable = new GitCommitTable();
    final CommitPanel panel = parameters.getPanel();
    panel.amendCheckBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            gitCommitTable.setAmend(panel.amendCheckBox.isSelected());
        }
    });
    return new GitCommitPanel(gitCommitTable, roots, repository, parameters, preferences, hooks, hooksCtx, diffProvider, fromGitView, createFilters(fromGitView));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:GitCommitPanel.java

示例6: displayAlert

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * Just show the dialog but do not do anything about it.
 */
private boolean displayAlert(String projectDisplayName) {
    String title = NbBundle.getMessage(UnboundTargetAlert.class, "UTA_TITLE", label, projectDisplayName);
    final DialogDescriptor d = new DialogDescriptor(this, title);
    d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    d.setMessageType(NotifyDescriptor.ERROR_MESSAGE);
    d.setValid(false);
    selectCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            d.setValid(((String) selectCombo.getSelectedItem()).trim().length() > 0);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(d);
    selectCombo.requestFocusInWindow();
    // XXX combo box gets cut off at the bottom unless you do something - why??
    Dimension sz = dlg.getSize();
    dlg.setSize(sz.width, sz.height + 30);
    dlg.setVisible(true);
    return d.getValue() == NotifyDescriptor.OK_OPTION;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:UnboundTargetAlert.java

示例7: DeviceSelector

import java.awt.event.ItemListener; //导入依赖的package包/类
public DeviceSelector(Controller controller) {
    super(controller);
    selector = new javax.swing.JComboBox();
    label = new javax.swing.JLabel("");

    panel = new javax.swing.JPanel(new java.awt.BorderLayout(0,1));
    panel.add(label, java.awt.BorderLayout.NORTH);
    panel.add(selector, java.awt.BorderLayout.SOUTH);
    panel.setBorder(new javax.swing.border.EmptyBorder(3,3,3,3));
    actionHash = new HashMap<String,IAction>();
    
    //listener to combo box gets value and initiates action
    selector.addItemListener( new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            if (event.getStateChange() == ItemEvent.DESELECTED) return;
            IAction action = actionHash.get(event.getItem());
            doAction(action);
        }
    });
}
 
开发者ID:etomica,项目名称:etomica,代码行数:21,代码来源:DeviceSelector.java

示例8: getPopupMenuItem

import java.awt.event.ItemListener; //导入依赖的package包/类
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
    
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(
        NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
        toolbarVisible);
    
    item.addItemListener( new ItemListener() {
        public @Override void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    
    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NbEditorKit.java

示例9: show

import java.awt.event.ItemListener; //导入依赖的package包/类
private void show(Window window) {
    JButton jButton = new JButton("Show ColorChooser");
    jButton.setActionCommand("Show ColorChooser");
    jButton.addActionListener(this);
    this.cbPlaf = new JComboBox<UIManager.LookAndFeelInfo>(UIManager.getInstalledLookAndFeels());
    this.cbPlaf.addItemListener(new ItemListener(){

        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == 1) {
                SwingUtilities.invokeLater(new Runnable(){

                    @Override
                    public void run() {
                        UIManager.LookAndFeelInfo lookAndFeelInfo = (UIManager.LookAndFeelInfo)Test4319113.this.cbPlaf.getSelectedItem();
                        try {
                            UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                            Frame[] arrframe = Frame.getFrames();
                            int n = arrframe.length;
                            while (--n >= 0) {
                                Test4319113.updateWindowTreeUI(arrframe[n]);
                            }
                        }
                        catch (Exception var2_3) {
                            System.err.println("Exception while changing L&F!");
                        }
                    }
                });
            }
        }

    });
    window.add(this.cbPlaf);
    window.add(jButton);
    window.pack();
    window.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:Test4319113.java

示例10: getJComboBoxJVMMemoryMaximum

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * This method initializes jComboBoxJVMMemoryMaximum	
 * @return javax.swing.JComboBox	
 */
private JComboBox<String> getJComboBoxJVMMemoryMaximum() {
	if (jComboBoxJVMMemoryMaximum == null) {
		jComboBoxJVMMemoryMaximum = new JComboBox<String>();
		jComboBoxJVMMemoryMaximum.setModel(comboModelMaximal);
		jComboBoxJVMMemoryMaximum.setPreferredSize(new Dimension(80, 26));
		jComboBoxJVMMemoryMaximum.addItemListener(new ItemListener() {
			@Override
			public void itemStateChanged(ItemEvent ie) {
				if (ie.getStateChange()==ItemEvent.SELECTED) {
					@SuppressWarnings("unchecked")
					JComboBox<String> combo = (JComboBox<String>) ie.getSource();
					if (isMemorySelectionError(combo)==false) {
						// --- Save in project ------------
						currRemoteContainerConfiguration.setJvmMemAllocMaximum((String) jComboBoxJVMMemoryMaximum.getSelectedItem());
						currProject.setRemoteContainerConfiguration(currRemoteContainerConfiguration);
					} else {
						// --- Set back to old value ------
						getJComboBoxJVMMemoryMaximum().setSelectedItem(currRemoteContainerConfiguration.getJvmMemAllocMaximum());
					}
				}
			}
		});
	}
	return jComboBoxJVMMemoryMaximum;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:Distribution.java

示例11: createTypeMenu

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * @return menu that allows to select possible column types
 */
private JMenu createTypeMenu() {
	ButtonGroup typeGroup = new ButtonGroup();
	JMenu typeChangeItem = new JMenu(CHANGE_TYPE_LABEL);
	typeChangeItem.setToolTipText(CHANGE_TYPE_TIP);
	for (final ColumnType columnType : ColumnType.values()) {
		final JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(
				DataImportWizardUtils.getNameForColumnType(columnType));
		if (columnType == metaData.getColumnMetaData(columnIndex).getType()) {
			checkboxItem.setSelected(true);
		}
		checkboxItem.addItemListener(new ItemListener() {

			@Override
			public void itemStateChanged(ItemEvent e) {
				if (e.getStateChange() == ItemEvent.SELECTED) {
					changeType(columnType);
				}

			}
		});
		typeGroup.add(checkboxItem);
		typeChangeItem.add(checkboxItem);
	}
	return typeChangeItem;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:ConfigureDataTableHeader.java

示例12: updateOperatorCombo

import java.awt.event.ItemListener; //导入依赖的package包/类
private void updateOperatorCombo() {
	Object selectedItem = this.operatorCombo.getSelectedItem();
	this.operatorCombo.removeAllItems();
	List<Operator> allInnerOps = parentOperator.getAllInnerOperators();
	Vector<String> allOpNames = new Vector<String>();
	Iterator<Operator> i = allInnerOps.iterator();
	while (i.hasNext()) {
		allOpNames.add(i.next().getName());
	}
	Collections.sort(allOpNames);
	Iterator<String> s = allOpNames.iterator();
	while (s.hasNext()) {
		this.operatorCombo.addItem(s.next());
	}
	this.operatorCombo.addItemListener(new ItemListener() {

		@Override
		public void itemStateChanged(ItemEvent e) {
			fireEditingStopped();
		}
	});
	if (this.operatorCombo.getItemCount() == 0) {
		this.operatorCombo.addItem("add inner operators");
	}
	this.operatorCombo.setSelectedItem(selectedItem);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:InnerOperatorValueCellEditor.java

示例13: addInputCombo

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * Adds an input field to select from a ComboBox
 * @param text text to be shown on a label
 * @param property property to be changed in Defaults
 * @param cont container where input field must be added
 * @param values Map with internal value <-> showed value relations
 */
protected void addInputCombo(String text, final String property, Container cont, final Map<String, String> values) {
	JLabel label = new JLabel(text + ":");
	JComboBox combo = new JComboBox(values.values().toArray());
	combo.setName(property);
	label.setLabelFor(combo);
	combo.setSelectedItem(values.get(Defaults.get(property)));
	// Sets maximum size to minimal one, otherwise springLayout will stretch this
	combo.setMaximumSize(new Dimension(combo.getMaximumSize().width, combo.getMinimumSize().height));
	combo.addItemListener(new ItemListener() {
		public void itemStateChanged(ItemEvent e) {
			// As Map does not allows reverse mapping, scans the entire keyset to
			// find the key corresponding to a given object
			Object[] keys = values.keySet().toArray();
			for (Object key : keys) {
				if (values.get(key) == e.getItem()) {
					Defaults.set(property, (String) key);
				}
			}
		}
	});
	cont.add(label);
	cont.add(combo);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:31,代码来源:DefaultsEditor.java

示例14: addBooleanComboBox

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * Adds a ComboBox to select a boolean property
 * @param text text to be shown on a label
 * @param property property to be changed in Defaults
 * @param cont container where input field must be added
 */
protected void addBooleanComboBox(String text, final String property, Container cont) {
	JLabel label = new JLabel(text + ":");
	JComboBox combo = new JComboBox(new Object[] { Boolean.TRUE.toString(), Boolean.FALSE.toString() });
	combo.setName(property);
	label.setLabelFor(combo);
	combo.setSelectedItem(Defaults.get(property));
	// Sets maximum size to minimal one, otherwise springLayout will stretch this
	combo.setMaximumSize(new Dimension(combo.getMaximumSize().width, combo.getMinimumSize().height));
	combo.addItemListener(new ItemListener() {
		public void itemStateChanged(ItemEvent e) {
			Defaults.set(property, (String) e.getItem());
		}
	});
	cont.add(label);
	cont.add(combo);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:23,代码来源:DefaultsEditor.java

示例15: addEnableControl

import java.awt.event.ItemListener; //导入依赖的package包/类
/**
 * Add a control for enablement
 * 
 * @param text The label to be associated with the check box
 * @param listener The listener to be notified of updates to the new control
 */
private void addEnableControl(String text, ItemListener listener) {
	JCheckBox enableControl = new JCheckBox("Enable " + text);
	enableControl.setBounds(10, offset, 200, 20);
	enableControl.addItemListener(listener);
	add(enableControl);

	controlToValueName.put(enableControl, text);
	valueNameToControl.put(text, enableControl);
	offset += 25;
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:17,代码来源:WhiskasPanel.java


注:本文中的java.awt.event.ItemListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。