java.awt.event.ItemEvent Java Examples
The following examples show how to use
java.awt.event.ItemEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColorComboBox.java From netbeans with Apache License 2.0 | 6 votes |
/** * Initialize the combo with given list of Colors. * @param values Color values. * @param names Name of colors. * @param allowCustomColors True to allow users to pick a custom colors, * false if user can choose from given colors only. */ public ColorComboBox( Color[] values, String[] names, boolean allowCustomColors ) { super.setModel( createModel(values, names, allowCustomColors) ); this.allowCustomColors = allowCustomColors; setEditable( false ); setRenderer( new ColorComboBoxRendererWrapper( this ) ); if( allowCustomColors ) { addItemListener( new ItemListener() { @Override public void itemStateChanged( ItemEvent e ) { if( e.getStateChange() == ItemEvent.SELECTED ) { SwingUtilities.invokeLater( new Runnable() { @Override public void run() { if( getSelectedItem() == ColorValue.CUSTOM_COLOR ) { pickCustomColor(); } lastSelection = ( ColorValue ) getSelectedItem(); } } ); } } }); } }
Example #2
Source File: SelectPackageTemplateDialog.java From PackageTemplates with Apache License 2.0 | 6 votes |
private void makePathButton() { btnPath = new TextFieldWithBrowseButton(); btnPath.setText(PackageTemplateHelper.getRootDirPath()); btnPath.addBrowseFolderListener(Localizer.get("SelectPackageTemplate"), "", project, FileReaderUtil.getPackageTemplatesDescriptor()); // panel.add(new SeparatorComponent(), new CC().growX().spanX().wrap()); panel.add(btnPath, new CC().pushX().growX().spanX()); addPathButtons(); rbFromPath = new JBRadioButton(Localizer.get("label.FromPath")); rbFromPath.addItemListener(e -> { if (e.getStateChange() == ItemEvent.SELECTED) { toggleSourcePath( TemplateSourceType.PATH, null, btnPath ); } }); panel.add(rbFromPath, new CC().growX().spanX().wrap()); }
Example #3
Source File: CustomMechDialog.java From megamek with GNU General Public License v2.0 | 6 votes |
public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getSource().equals(choStartingMode)) { updateStartingModeOptions(); } if (itemEvent.getSource().equals(chDeployProne)) { chDeployHullDown.setSelected(false); return; } if (itemEvent.getSource().equals(chDeployHullDown)) { chDeployProne.setSelected(false); return; } if (itemEvent.getSource().equals(choDeploymentRound)) { if (choDeploymentRound.getSelectedIndex() == 0) { choDeploymentZone.setEnabled(false); choDeploymentZone.setSelectedIndex(0); } else { choDeploymentZone.setEnabled(true); } } }
Example #4
Source File: InteractiveIntegral.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@Override public void itemStateChanged( final ItemEvent arg0 ) { boolean oldState = lookForMaxima; if ( arg0.getStateChange() == ItemEvent.DESELECTED ) lookForMaxima = false; else if ( arg0.getStateChange() == ItemEvent.SELECTED ) lookForMaxima = true; if ( lookForMaxima != oldState ) { while ( isComputing ) SimpleMultiThreading.threadWait( 10 ); updatePreview( ValueChange.MINMAX ); } }
Example #5
Source File: DrawingViewPlacardPanel.java From openAGV with Apache License 2.0 | 6 votes |
/** * Creates a button to toggle the blocks in the drawing. * * @param view The DrawingView the button will belong to. * @return The created button. */ private JToggleButton toggleBlocksButton(final OpenTCSDrawingView drawingView) { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setToolTipText( labels.getString("drawingViewPlacardPanel.button_toggleBlocks.tooltipText") ); toggleButton.setIcon(ImageDirectory.getImageIcon("/tree/block.18x18.png")); toggleButton.setMargin(new Insets(0, 0, 0, 0)); toggleButton.setFocusable(false); toggleButton.addItemListener( (ItemEvent event) -> drawingView.setBlocksVisible(toggleButton.isSelected()) ); return toggleButton; }
Example #6
Source File: DriverGUI.java From openAGV with Apache License 2.0 | 6 votes |
/** * If a loopback adapter was chosen, this method initializes the combo boxes * with positions the user can set the vehicle to. * * @param rowIndex An index indicating which row this combo box belongs to * @param pointsCellEditor The <code>SingleCellEditor</code> containing * the combo boxes. */ private void initPointsComboBox(int rowIndex, SingleCellEditor pointsCellEditor) { final JComboBox<Point> pointComboBox = new JComboBox<>(); objectService.fetchObjects(Point.class).stream() .sorted(Comparators.objectsByName()) .forEach(point -> pointComboBox.addItem(point)); pointComboBox.setSelectedIndex(-1); pointComboBox.setRenderer(new StringListCellRenderer<>(x -> x == null ? "" : x.getName())); pointComboBox.addItemListener((ItemEvent e) -> { Point newPoint = (Point) e.getItem(); VehicleEntry vehicleEntry = vehicleEntryPool.getEntryFor(getSelectedVehicleName()); if (vehicleEntry.getCommAdapter() instanceof SimVehicleCommAdapter) { SimVehicleCommAdapter adapter = (SimVehicleCommAdapter) vehicleEntry.getCommAdapter(); adapter.initVehiclePosition(newPoint.getName()); } else { LOG.debug("Vehicle {}: Not a simulation adapter -> not setting initial position.", vehicleEntry.getVehicle().getName()); } }); pointsCellEditor.setEditorAt(rowIndex, new DefaultCellEditor(pointComboBox)); }
Example #7
Source File: FcdProPlusPanel.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
@Override public void itemStateChanged(ItemEvent e) { if (checkingSettings) return; if (e.getSource() == cbMixerGain) { if (e.getStateChange() == ItemEvent.DESELECTED) { setMixerGain(false); } else { setMixerGain(true); } } if (e.getSource() == cbLnaGain) { if (e.getStateChange() == ItemEvent.DESELECTED) { setLnaGain(false); } else { setLnaGain(true); } } if (e.getSource() == cbBiasTee ) { if (e.getStateChange() == ItemEvent.DESELECTED) { setBiasTee(false); } else { setBiasTee(true); } } }
Example #8
Source File: SettingsComponentFactory.java From stendhal with GNU General Public License v2.0 | 6 votes |
static JCheckBox createSettingsToggle(final String parameter, boolean defaultValue, String label, String tooltip) { boolean selected = false; JCheckBox toggle = new JCheckBox(label); toggle.setToolTipText(tooltip); selected = WtWindowManager.getInstance().getPropertyBoolean(parameter, defaultValue); toggle.setSelected(selected); toggle.addItemListener(new ItemListener(){ @Override public void itemStateChanged(ItemEvent e) { boolean enabled = (e.getStateChange() == ItemEvent.SELECTED); WtWindowManager.getInstance().setProperty(parameter, Boolean.toString(enabled)); } }); return toggle; }
Example #9
Source File: ConfigureDataTableHeader.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * (Re-)creates the type menu with the selected type * @param selected the selected column Type */ private void updateTypeMenu(String selected) { typeMenu.removeAll(); ButtonGroup typeGroup = new ButtonGroup(); for (ColumnType columnType : ColumnType.values()) { String columnTypeName = DataImportWizardUtils.getNameForColumnType(columnType); JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(columnTypeName); if (columnTypeName.equals(selected)) { checkboxItem.setSelected(true); } checkboxItem.addItemListener(e -> { if (e.getStateChange() == ItemEvent.SELECTED) { changeType(columnType); } }); typeGroup.add(checkboxItem); typeMenu.add(checkboxItem); } }
Example #10
Source File: CheckboxMenuItemGroup.java From proxyee-down with Apache License 2.0 | 6 votes |
@Override public void itemStateChanged(ItemEvent e) { CheckboxMenuItem checkedItem = ((CheckboxMenuItem) e.getSource()); if (e.getStateChange() == ItemEvent.SELECTED) { String selectedItemName = checkedItem.getName(); for (CheckboxMenuItem item : items) { if (!item.getName().equals(selectedItemName)) { item.setState(false); } } if (itemListener != null) { itemListener.itemStateChanged(e); } } else { checkedItem.setState(true); } }
Example #11
Source File: SyntaxTester.java From visualvm with GNU General Public License v2.0 | 6 votes |
private void jCmbLangsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCmbLangsItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { String lang = jCmbLangs.getSelectedItem().toString(); // save the state of the current JEditorPane, as it's Document is about // to be replaced. String t = jEdtTest.getText(); int caretPosition = jEdtTest.getCaretPosition(); Rectangle visibleRectangle = jEdtTest.getVisibleRect(); // install a new DefaultSyntaxKit on the JEditorPane for the requested language. jEdtTest.setContentType(lang); // restore the state of the JEditorPane - note that installing a new // EditorKit causes the Document to be recreated. SyntaxDocument sDoc = (SyntaxDocument) jEdtTest.getDocument(); jEdtTest.setText(t); sDoc.clearUndos(); jEdtTest.setCaretPosition(caretPosition); jEdtTest.scrollRectToVisible(visibleRectangle); } }
Example #12
Source File: GUIOptionInterceptDialog.java From PacketProxy with Apache License 2.0 | 6 votes |
private JComponent createDirectionSetting() { direction_combo.addItem(InterceptOption.getDirectionAsString(Direction.REQUEST)); direction_combo.addItem(InterceptOption.getDirectionAsString(Direction.RESPONSE)); direction_combo.setSelectedIndex(0); direction_combo.setEnabled(true); direction_combo.setMaximumRowCount(2); direction_combo.addItemListener(new ItemListener(){ @Override public void itemStateChanged(ItemEvent event) { try { if (event.getStateChange() != ItemEvent.SELECTED) return; String selectedItem = (String)event.getItem(); updateRelationship(selectedItem); } catch (Exception e) { e.printStackTrace(); } } }); return label_and_object(I18nString.get("Direction:"), direction_combo); }
Example #13
Source File: LWCheckboxPeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void itemStateChanged(final ItemEvent e) { // group.setSelectedCheckbox() will repaint the component // to let LWCheckboxPeer correctly handle it we should call it // after the current event is processed SwingUtilities.invokeLater(new Runnable() { @Override public void run() { boolean postEvent = true; final CheckboxGroup group = getTarget().getCheckboxGroup(); if (group != null) { if (e.getStateChange() == ItemEvent.SELECTED) { if (group.getSelectedCheckbox() != getTarget()) { group.setSelectedCheckbox(getTarget()); } else { postEvent = false; } } else { postEvent = false; if (group.getSelectedCheckbox() == getTarget()) { // Don't want to leave the group with no selected // checkbox. getTarget().setState(true); } } } else { getTarget().setState(e.getStateChange() == ItemEvent.SELECTED); } if (postEvent) { postEvent(new ItemEvent(getTarget(), ItemEvent.ITEM_STATE_CHANGED, getTarget().getLabel(), e.getStateChange())); } } }); }
Example #14
Source File: VerticalChoicesPanel.java From ghidra with Apache License 2.0 | 5 votes |
/** * Adds a row with the items in each column. The first item's component is a radio button. * @param items the text for each column. * @param name the name for the radio button component. * @param conflictOption the conflict option value associated with selecting this row's radio button. * @param listener listener to be notified when the radio button is selected. */ void addRadioButtonRow(final String[] items, final String name, final int conflictOption, final ChangeListener listener) { adjustColumnCount(items.length); final int row = rows.size(); rowTypes.add(RADIO_BUTTON); rows.add(items); final MyRadioButton firstComp = new MyRadioButton(items[0], conflictOption); group.add(firstComp); firstComp.setName(name); ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (listener != null && ((JRadioButton) e.getSource()).isSelected()) { ResolveConflictChangeEvent event = new ResolveConflictChangeEvent(firstComp, row, getSelectedOptions()); listener.stateChanged(event); } } }; firstComp.addItemListener(itemListener); setRowComponent(firstComp, row, 0, defaultInsets); for (int i = 1; i < items.length; i++) { MyLabel newComp = new MyLabel(items[i]); newComp.setName(getComponentName(row, i)); setRowComponent(newComp, row, i, textVsButtonInsets); } rowPanel.validate(); validate(); invalidate(); }
Example #15
Source File: TechPanel.java From zap-extensions with Apache License 2.0 | 5 votes |
ZapToggleButton getEnableToggleButton() { if (enableButton == null) { enableButton = new ZapToggleButton( Constant.messages.getString("wappalyzer.toolbar.toggle.state.enabled"), true); enableButton.setIcon( new ImageIcon( TechPanel.class.getResource( ExtensionWappalyzer.RESOURCE + "/off.png"))); enableButton.setToolTipText( Constant.messages.getString( "wappalyzer.toolbar.toggle.state.disabled.tooltip")); enableButton.setSelectedIcon( new ImageIcon( TechPanel.class.getResource(ExtensionWappalyzer.RESOURCE + "/on.png"))); enableButton.setSelectedToolTipText( Constant.messages.getString("wappalyzer.toolbar.toggle.state.enabled.tooltip")); enableButton.addItemListener( event -> { if (event.getStateChange() == ItemEvent.SELECTED) { enableButton.setText( Constant.messages.getString( "wappalyzer.toolbar.toggle.state.enabled")); extension.setWappalyzer(true); } else { enableButton.setText( Constant.messages.getString( "wappalyzer.toolbar.toggle.state.disabled")); extension.setWappalyzer(false); } }); } return enableButton; }
Example #16
Source File: DefaultSuiteProjectDeletePanel.java From netbeans with Apache License 2.0 | 5 votes |
private void attachListeners() { this.deleteModulesCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if(deleteModulesCheckBox.isSelected() && hasSourcesToDelete) { deleteSourcesCheckBox.setEnabled(true); } else { deleteSourcesCheckBox.setEnabled(false); } } }); }
Example #17
Source File: ScrollingListChoicesPanel.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void itemStateChanged(ItemEvent e) { if (listener != null) { Object source = e.getSource(); if (((JRadioButton) source).isSelected()) { ResolveConflictChangeEvent re = new ResolveConflictChangeEvent(source, 0, getUseForAllChoice()); listener.stateChanged(re); } } }
Example #18
Source File: PCGenMenuBar.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { Object item = e.getItemSelectable().getSelectedObjects()[0]; if (frame.loadSourceSelection((SourceSelectionFacade) item)) { setSelectedItem(uiContext.getCurrentSourceSelectionRef().get()); } } }
Example #19
Source File: LWChoicePeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void itemStateChanged(final ItemEvent e) { // AWT Choice sends SELECTED event only whereas JComboBox // sends both SELECTED and DESELECTED. if (e.getStateChange() == ItemEvent.SELECTED) { synchronized (getDelegateLock()) { if (skipPostMessage) { return; } getTarget().select(getDelegate().getSelectedIndex()); } postEvent(new ItemEvent(getTarget(), ItemEvent.ITEM_STATE_CHANGED, e.getItem(), ItemEvent.SELECTED)); } }
Example #20
Source File: RoboVmGlobalConfigForm.java From robovm-idea with GNU General Public License v2.0 | 5 votes |
public RoboVmGlobalConfigForm(final RoboVmGlobalConfig config) { super(); updateConfig(config); compileOnSaveRequiredCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { config.setCompileOnSave(compileOnSaveRequiredCheckBox.isSelected()); } }); }
Example #21
Source File: TransferSelector.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { model.selectAll(); treeView.repaintTree(); } else if (e.getStateChange() == ItemEvent.DESELECTED) { model.unselectAll(); treeView.repaintTree(); } }
Example #22
Source File: LWChoicePeer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void itemStateChanged(final ItemEvent e) { // AWT Choice sends SELECTED event only whereas JComboBox // sends both SELECTED and DESELECTED. if (e.getStateChange() == ItemEvent.SELECTED) { synchronized (getDelegateLock()) { if (skipPostMessage) { return; } getTarget().select(getDelegate().getSelectedIndex()); } postEvent(new ItemEvent(getTarget(), ItemEvent.ITEM_STATE_CHANGED, e.getItem(), ItemEvent.SELECTED)); } }
Example #23
Source File: DrawTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@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); } } }
Example #24
Source File: WListPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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)); } }); }
Example #25
Source File: DefinitionsPanel.java From netbeans with Apache License 2.0 | 5 votes |
public void itemStateChanged(ItemEvent e) { if(defaultPackageCB.isSelected()){ packageNameText.setEnabled(false); } else{ packageNameText.setEnabled(true); packageNameText.requestFocus(); } }
Example #26
Source File: ValueFunctionVisualizerGUI.java From burlap with Apache License 2.0 | 5 votes |
/** * Called when the check back for the policy rendering is checked or unchecked. */ public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if(source == this.showPolicy){ if(this.showPolicy.isSelected()){ this.pLayer.setSpp(spp); } else{ this.pLayer.setSpp(null); } this.visualizer.repaint(); } }
Example #27
Source File: AttributeFilters.java From ghidra with Apache License 2.0 | 5 votes |
/** * alert listeners that there is a change in the selected filters * @param e the event */ protected void fireItemStateChanged(ItemEvent e) { // Guaranteed to return a non-null array Object[] listeners = listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ItemListener.class) { ((ItemListener) listeners[i + 1]).itemStateChanged(e); } } }
Example #28
Source File: LimitRowsCheckBoxActionListener.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void itemStateChanged( final ItemEvent e ) { final Object source = e.getSource(); if ( source instanceof AbstractButton ) { final AbstractButton b = (AbstractButton) source; maxPreviewRowsSpinner.setEnabled( b.isSelected() ); } }
Example #29
Source File: PayloadPreviewPanel.java From zap-extensions with Apache License 2.0 | 5 votes |
private static JPanel createSplitPanel( JPanel leftPanel, JPanel rightPanel, final SyncScrollBarsAdjustmentListener syncScrollPanes) { JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutoCreateGaps(true); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); splitPane.setDividerLocation(0.5D); splitPane.setResizeWeight(0.5D); JCheckBox syncScrollBarsCheckbox = new JCheckBox(LOCK_SCROLL_BARS_BUTTON_LABEL); syncScrollBarsCheckbox.setSelected(true); syncScrollBarsCheckbox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { syncScrollPanes.setSync(e.getStateChange() == ItemEvent.SELECTED); } }); layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(splitPane) .addComponent(syncScrollBarsCheckbox)); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(splitPane) .addComponent(syncScrollBarsCheckbox)); return panel; }
Example #30
Source File: DrawTest.java From hottub with GNU General Public License v2.0 | 5 votes |
@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); } } }