本文整理汇总了Java中java.awt.event.ItemEvent类的典型用法代码示例。如果您正苦于以下问题:Java ItemEvent类的具体用法?Java ItemEvent怎么用?Java ItemEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemEvent类属于java.awt.event包,在下文中一共展示了ItemEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ComboBoxFrame
import java.awt.event.ItemEvent; //导入依赖的package包/类
public ComboBoxFrame()
{
super("Testing JComboBox");
setLayout(new FlowLayout()); // set frame layout
imagesJComboBox = new JComboBox<String>(names); // set up JComboBox
imagesJComboBox.setMaximumRowCount(3); // display three rows
add(imagesJComboBox); // add combobox to JFrame
label = new JLabel(icons[0]); // display first icon
add(label); // add label to JFrame
imagesJComboBox.addItemListener(event -> {
if (event.getStateChange() == ItemEvent.SELECTED)
label.setIcon(icons[imagesJComboBox.getSelectedIndex()]);
}); // end call to addItemListener
}
示例2: comboCountry_Change
import java.awt.event.ItemEvent; //导入依赖的package包/类
private void comboCountry_Change(ItemEvent e) {
if(comboCountry.getSelectedIndex() > 0) {
List<Location> locs = locationDao.queryAllLocationsByPid(((Location)comboCountry.getSelectedItem()).id);
if(locs.isEmpty()) {
lblState.setVisible(false);
comboState.setModel(new DefaultComboBoxModel());
comboState.setVisible(false);
} else {
lblState.setVisible(true);
DefaultComboBoxModel model = new DefaultComboBoxModel();
model.addElement("请选择...");
for(Location loc : locs)
model.addElement(loc);
comboState.setModel(model);
comboState.setVisible(true);
}
} else {
lblState.setVisible(false);
comboState.setModel(new DefaultComboBoxModel());
comboState.setVisible(false);
}
}
示例3: CheckBoxWithText
import java.awt.event.ItemEvent; //导入依赖的package包/类
/**
*
*/
public CheckBoxWithText(String title) {
super();
setText(title);
super.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
if (e.getStateChange() == ItemEvent.SELECTED) {
textField.setEnabled(true);
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
textField.setEnabled(false);
}
}
});
}
示例4: Ed
import java.awt.event.ItemEvent; //导入依赖的package包/类
public Ed(ReportState piece) {
box = new JPanel();
box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
descInput = new StringConfigurer(null, "Description: ", piece.description);
box.add(descInput.getControls());
keys = new NamedKeyStrokeArrayConfigurer(null, "Report on these keystrokes: ", piece.keys);
box.add(keys.getControls());
cycle = new JCheckBox("Cycle through different messages?");
box.add(cycle);
format = new PlayerIdFormattedStringConfigurer(null, "Report format: ", new String[]{COMMAND_NAME,
OLD_UNIT_NAME,
NEW_UNIT_NAME,
MAP_NAME,
OLD_MAP_NAME,
LOCATION_NAME,
OLD_LOCATION_NAME});
format.setValue(piece.reportFormat);
box.add(format.getControls());
cycleFormat = new StringArrayConfigurer(null, "Message formats", piece.cycleReportFormat);
box.add(cycleFormat.getControls());
cycleDownKeys = new NamedKeyStrokeArrayConfigurer(null, "Report previous message on these keystrokes: ", piece.cycleDownKeys);
box.add(cycleDownKeys.getControls());
ItemListener l = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
format.getControls().setVisible(!cycle.isSelected());
cycleFormat.getControls().setVisible(cycle.isSelected());
cycleDownKeys.getControls().setVisible(cycle.isSelected());
Window w = SwingUtilities.getWindowAncestor(box);
if (w != null) {
w.pack();
}
}
};
l.itemStateChanged(null);
cycle.addItemListener(l);
cycle.setSelected(piece.cycleReportFormat.length > 0);
}
示例5: attachListeners
import java.awt.event.ItemEvent; //导入依赖的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
示例6: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(ItemEvent e) {
Background newBackground
= (Background)this.background.getSelectedItem();
Decoration newDecoration
= (Decoration)this.decoration.getSelectedItem();
UnionPosition newPosition
= (UnionPosition)this.unionPosition.getSelectedItem();
UnionShape newShape
= (UnionShape)this.unionShape.getSelectedItem();
this.flag = new Flag(newBackground, newDecoration,
newPosition, newShape);
this.flag.setStars(this.stars.getSelectedIndex() + 1);
this.flag.setStripes(this.stripes.getSelectedIndex() + 1);
setColors();
this.label.setIcon(new ImageIcon(this.flag.getImage()));
}
示例7: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getItem() == mouseToolbarCheckbox) {
toolbars.getMouseToolbar().setVisible(mouseToolbarCheckbox.getState() );
} else if (e.getItem() == zoomToolbarCheckbox) {
toolbars.getZoomToolbar().setVisible(zoomToolbarCheckbox.getState() );
} else if (e.getItem() == simulationToolbarCheckbox) {
toolbars.getSimulationToolbar().setVisible(simulationToolbarCheckbox.getState() );
} else if (e.getItem() == dbToolbarCheckbox) {
toolbars.getDBToolbar().setVisible(dbToolbarCheckbox.getState() );
} else if (e.getItem() == undoToolbarCheckbox) {
toolbars.getUndoToolbar().setVisible(undoToolbarCheckbox.getState());
} else {
System.err.println("Unknown event");
}
}
示例8: setupImportRootButtons
import java.awt.event.ItemEvent; //导入依赖的package包/类
private void setupImportRootButtons() {
if (projectCreationRootOptionButtonGroup.isEmpty()) {
projectCreationRootOptionButtonGroup.add(importIntoDefaultProjectOption);
projectCreationRootOptionButtonGroup.add(createProjectInSelectedRootOption);
projectCreationRootOptionButtonGroup.add(importProjectIntoCustomRootOption);
for (JRadioButton radioButton : projectCreationRootOptionButtonGroup) {
if (radioButton == importProjectIntoCustomRootOption) {
importProjectIntoCustomRootOption.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
customImportRootDirectoryBrowser.setVisible(true);
customImportRootDirectoryBrowser.setEnabled(true);
} else {
customImportRootDirectoryBrowser.setVisible(false);
customImportRootDirectoryBrowser.setEnabled(false);
}
refreshProjectCreationPreview();
});
} else {
radioButton.addItemListener(e -> refreshProjectCreationPreview());
}
}
}
}
示例9: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
@Override
public void itemStateChanged(ItemEvent event) {
if ( event.getSource() == jComboBoxMtpProtocol){
if (this.getJcomboBoxMtpProtocol().getSelectedProtocol()==MtpProtocol.HTTP) {
// ---- switch to HTTP ----------------------------------
this.setHttpsComponentsEnabledState(false);
this.currProject.getJadeConfiguration().setMtpProtocol(MtpProtocol.HTTP);
this.getJTextFieldKeyStoreFile().setText(null);
this.getJTextFieldTrustStoreFile().setText(null);
} else if (this.getJcomboBoxMtpProtocol().getSelectedProtocol()==MtpProtocol.HTTPS) {
// ---- switch to HTTPS ------------------------------
this.setHttpsComponentsEnabledState(true);
this.editHTTPSsettings(event.getSource(), MtpProtocol.HTTPS);
} else if(this.getJcomboBoxMtpProtocol().getSelectedProtocol()==MtpProtocol.PROXIEDHTTPS){
this.setHttpsComponentsEnabledState(true);
this.editHTTPSsettings(event.getSource(), MtpProtocol.PROXIEDHTTPS);
}
}
}
示例10: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
@Override
public void itemStateChanged(ItemEvent e) {
setHButtonEnable();
if (rec)
return;
rec = true;
try {
if ((e.getStateChange() == ItemEvent.SELECTED)
&& (hierarchies.getSelectedIndex() == hierarchies
.getItemCount() - 1)) {
createNewHierarchy();
}
} finally {
rec = false;
}
}
示例11: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
public void itemStateChanged( ItemEvent e ) {
Object source = e.getSource();
if ( source instanceof JCheckBoxMenuItem ) {
JCheckBoxMenuItem cbmi = (JCheckBoxMenuItem) source;
if ( cbmi == displayGridCBMI )
fp.setGridDisplay( displayGridCBMI.getState() );
else if ( cbmi == force16ColsCBMI )
fp.setForce16Columns( force16ColsCBMI.getState() );
else if ( cbmi == showFontInfoCBMI ) {
if ( showFontInfoCBMI.getState() ) {
fireUpdateFontInfo();
fontInfoDialog.show();
}
else
fontInfoDialog.hide();
}
}
}
示例12: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
@Override final public void itemStateChanged(ItemEvent objPitemEvent) {
Tools.debug("DataJToggleButton.itemStateChanged()");
switch (this.bytGtype) {
case DataJToggleButton.bytS_CLOSE_WINDOW:
this.objGdataJFrame.windowClosing(null);
this.removeItemListener(this);
this.setSelected(false);
this.addItemListener(this);
break;
case DataJToggleButton.bytS_CONTENT_ADJUSTMENT:
case DataJToggleButton.bytS_WINDOW_ADJUSTMENT:
final boolean bolLselected = objPitemEvent.getStateChange() == ItemEvent.SELECTED;
this.objGdataJFrame.doToggleJButtons(this.bytGtype, bolLselected);
if (bolLselected) {
this.objGdataJFrame.doAdjustFields(this.bytGtype == DataJToggleButton.bytS_WINDOW_ADJUSTMENT);
}
this.setText();
break;
}
}
示例13: getTreeCellEditorComponent
import java.awt.event.ItemEvent; //导入依赖的package包/类
@Override
public Component getTreeCellEditorComponent(final JTree tree,
final Object value, final boolean selected, final boolean expanded,
final boolean leaf, final int row) {
final Component editor =
renderer.getTreeCellRendererComponent(tree, value, true, expanded, leaf,
row, true);
// editor always selected / focused
final ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent itemEvent) {
if (stopCellEditing()) {
fireEditingStopped();
}
}
};
if (editor instanceof CheckBoxNodePanel) {
final CheckBoxNodePanel panel = (CheckBoxNodePanel) editor;
panel.check.addItemListener(itemListener);
}
return editor;
}
示例14: displayAlert
import java.awt.event.ItemEvent; //导入依赖的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;
}
示例15: itemStateChanged
import java.awt.event.ItemEvent; //导入依赖的package包/类
public void itemStateChanged(ItemEvent e) {
String s = (String) e.getItem();
for (int i = 0; i < connTypes.length; i++) {
if (s.equals(connTypes[i][0])) {
mDriver.setText(connTypes[i][1]);
mURL.setText(connTypes[i][2]);
}
}
}