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 }
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); } }
/** * */ 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); } } }); }
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); }
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); } } }); } }); } }); }
/** * {@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())); }
@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"); } }
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()); } } } }
@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); } } }
@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; } }
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(); } } }
@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; } }
@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; }
/** * 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; }
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]); } } }
void handleListChanged(final int index) { final List l = (List)target; WToolkit.executeOnEventHandlerThread(l, new Runnable() { @Override public void run() { postEvent(new ItemEvent(l, ItemEvent.ITEM_STATE_CHANGED, Integer.valueOf(index), isSelected(index)? ItemEvent.SELECTED : ItemEvent.DESELECTED)); } }); }
@Override public void itemStateChanged(ItemEvent e) { if (e.getItemSelectable().equals(tipo)) { if (!tipo.getSelectedItem().equals("Seleccione")) { lblCodigo.setText("Codigo "+tipo.getSelectedItem()); btnBuscarCodigo.setEnabled(true); } else { btnBuscarCodigo.setEnabled(false); lblCodigo.setText("Codigo "); } return; } }
/** * Method declaration * * * @param e */ public void itemStateChanged(ItemEvent e) { ItemSelectable item = e.getItemSelectable(); if (item == lTable) { if (iSelectionStep == SELECT_SOURCE_TABLES) { String table = lTable.getSelectedItem(); int selected = ((Integer) e.getItem()).intValue(); for (int i = 0; i < tTable.size(); i++) { TransferTable t = (TransferTable) tTable.elementAt(i); if (t == null) { continue; } if (i == selected) { saveTable(); displayTable(t); updateEnabled(true); } } } } else { // it must be a checkbox saveTable(); updateEnabled(true); } }
public void itemStateChanged(ItemEvent e) { JMenuItem source = (JMenuItem)(e.getSource()); String s = "Item event detected.\n" + " Event source: " + source.getText() + " (an instance of " + source.getClass().getName() + ")\n" + " New state: " + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected":"unselected") + "\n\n"; System.err.println(s); }
/** * Method description * * @see * @param objPitemEvent */ @Override final public void itemStateChanged(ItemEvent objPitemEvent) { // this.setToolTipText(objPitemEvent.getStateChange() == ItemEvent.SELECTED); Tools.debug("FXJCheckBox.itemStateChanged()"); this.validate(); FXActions.doDisplayFX(this.objGcontrolJFrame, objPitemEvent.getStateChange() == ItemEvent.SELECTED); }
@Override public void itemStateChanged(ItemEvent e) { if (checkbox.isSelected()) { buttonPanel.enableButton(); } else { buttonPanel.disableButton(); } this.setMinimumSize(this.getPreferredSize()); // #214745 }
/** * {@inheritDoc} */ @Override public void itemStateChanged(ItemEvent e) { // When the unit type changes, we have to reset the role choices JComboBox<String> box = this.roleUI.getComponent(); DefaultComboBoxModel<String> model; boolean enable = false; UnitType type = (UnitType)this.typeUI.getComponent().getSelectedItem(); if (type != null && type.hasAbility(Ability.CAN_BE_EQUIPPED)) { final Specification spec = type.getSpecification(); final NationType nt = getOption().getNationType(); int n = 0; model = new DefaultComboBoxModel<>(); for (String ri : getOption().getRole().getChoices()) { Role role = spec.getRole(ri); if (role.isAvailableTo(type, nt)) { model.addElement(ri); n++; } } enable = isEditable() && n > 1; } else { model = new DefaultComboBoxModel<>(new String[] { Specification.DEFAULT_ROLE_ID }); } box.setModel(model); box.setEnabled(enable); }
@SuppressWarnings("nls") public ComboBoxChoiceList(String labelText) { comboBox = new JComboBox<>(); comboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { NameValue nv = (NameValue) e.getItem(); if( nv != null ) { if( e.getStateChange() == ItemEvent.SELECTED ) { choiceSelected(nv); } else if( e.getStateChange() == ItemEvent.DESELECTED ) { choiceDeselected(nv); } } } }); choiceSink = new JPanel(new GridLayout(1, 1)); setLayout(new MigLayout("insets 0, hidemode 3", "[][grow]")); if( labelText != null ) { add(new JLabel(labelText)); } add(comboBox, "cell 1 0"); add(choiceSink, "cell 0 1, span"); changeDetector.watch(comboBox); }
public void itemStateChanged(ItemEvent e) { state = e.getStateChange() == ItemEvent.SELECTED; forEachPeer(new Functor<JCheckBoxMenuItem>() { public void apply(JCheckBoxMenuItem item) { item.setSelected(state); } }); }
private JComboBox<String> get_appearance_combo() { if(appearance_combo == null) { ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent event) { main.updateFrames(); } }; appearance_combo = tManager.createThemesComboBox(il); } return appearance_combo; }
@Override public void itemStateChanged(ItemEvent e) { final Object source = e.getSource(); assert source == chkPublic || source == chkProtected || source == chkPackage; callback.checkAcceptability(); }
public void itemStateChanged(ItemEvent e) { for (int i = 0; i < columns.length; i++) { if (komponente[i] == e.getSource()) { komponente[i].setChanged(); break; } } }
private void runSetFunction(ConnectorPresenter presenter, ItemEvent e) { if(operationInProgress || setRegionOperationInProgress || e.getStateChange() != ItemEvent.SELECTED) return; FunctionEntry entry = (FunctionEntry)e.getItem(); if(entry == null) return; runOperation(() -> presenter.setFunction(entry), "Select function: " + entry.toString()); }
/** * Override {@link ItemListener} for this panel's use. * This function evaluates whether a the user has * clicked the {@link #compactBox} or the * {@link #showAllBox} has been checked. * * {@inheritDoc} */ @Override public void itemStateChanged(ItemEvent event) { if (event.getSource() == this.compactBox) { updateDetailView(); updateCompact(this.compactBox.isSelected()); } else if (event.getSource() == this.showAllBox) { updateAllLists(); updateLists(this.showAllBox.isSelected()); } }
private void runSetTestFunctionInputFromRecent(ConnectorPresenter presenter, ItemEvent e) { if(operationInProgress || e.getStateChange() != ItemEvent.SELECTED) return; TestFunctionInputEntry entry = (TestFunctionInputEntry)e.getItem(); if(entry == null) return; runOperation(() -> presenter.setSetTestFunctionInputFromRecent(entry), "Select test function input from file: ", entry.getFileName()); }
private void sourceFolderItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_sourceFolderItemStateChanged if (ignoreEvent) { return; } if (evt.getStateChange() == ItemEvent.DESELECTED) { int index = findIndex(evt.getItem()); // if index == -1 then item was removed and will not be saved if (index != -1) { saveOutput(index); } } else { loadOutput(); } }
/** * Method description * * @see * @param objPitemEvent */ @Override final public void itemStateChanged(ItemEvent objPitemEvent) { Tools.debug("LightJCheckBox.itemStateChanged()"); this.validate(); FXActions.doSwitchLight(this.objGcontrolJFrame, objPitemEvent.getStateChange() == ItemEvent.SELECTED); }
/** Called when the Recursive check-box is toggled. */ @Override public void itemStateChanged(ItemEvent e) { assert e.getSource() == cbxRecursively; updateIsRecursive(); recursiveToggled(); }
@Override public void itemStateChanged(ItemEvent e) { if (e.getSource() instanceof Checkbox) { target.setForeground(((Component) e.getSource()).getForeground()); } else if (e.getSource() instanceof Choice) { String choice = (String) e.getItem(); if (choice.equals("Lines")) { target.setDrawMode(DrawPanel.LINES); } else if (choice.equals("Points")) { target.setDrawMode(DrawPanel.POINTS); } } }
@Override public void itemStateChanged(ItemEvent ie) { if (ie.getStateChange() == ItemEvent.SELECTED) { CardLayout layout = (CardLayout) repos.getLayout(); layout.show(repos, ((JToggleButton) ie.getSource()).getActionCommand()); } }