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


Java ItemEvent類代碼示例

本文整理匯總了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
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:17,代碼來源:ComboBoxFrame.java

示例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);
    }
}
 
開發者ID:hulang1024,項目名稱:PTEAssistant,代碼行數:23,代碼來源:UserSettingFrame.java

示例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);
			}
		}
		
	});
}
 
開發者ID:enocholumide,項目名稱:Laserscan-to-dxf,代碼行數:21,代碼來源:CheckBoxWithText.java

示例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);
    }
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:39,代碼來源:ReportState.java

示例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()));
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:21,代碼來源:ConfirmDeclarationDialog.java

示例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");
	}
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:17,代碼來源:ViewMenu.java

示例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());
            }
        }
    }
}
 
開發者ID:mistodev,項目名稱:processing-idea,代碼行數:26,代碼來源:ProcessingSketchRootSelectStep.java

示例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);
		}
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:20,代碼來源:JadeSetupMTP.java

示例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;
    }
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:17,代碼來源:TableViewPreferenciesDialog.java

示例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();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:Font2DTest.java

示例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;
	}

}
 
開發者ID:jugglemaster,項目名稱:JuggleMasterPro,代碼行數:22,代碼來源:DataJToggleButton.java

示例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;
}
 
開發者ID:berniejenny,項目名稱:MapAnalyst,代碼行數:27,代碼來源:CheckBoxNodeEditor.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:UnboundTargetAlert.java

示例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]);
            }
        }
    }
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:12,代碼來源:ConnectionDialogSwing.java


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