Java Code Examples for java.awt.event.ItemListener

The following are top voted examples for showing how to use java.awt.event.ItemListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: my-diploma-work   File: IngredientsFrame.java   View source code 8 votes vote down vote up
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();
}
 
Example 2
Project: incubator-netbeans   File: ActionFactory.java   View source code 7 votes vote down vote up
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;
}
 
Example 3
Project: cuttlefish   File: GroupPanel.java   View source code 6 votes vote down vote up
/**
 * 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);
		}
	}
}
 
Example 4
Project: incubator-netbeans   File: InternationalizationResourceBundleBrandingPanel.java   View source code 6 votes vote down vote up
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);
                            }
                        }
                    });
                }
            });
        }
    });
}
 
Example 5
Project: incubator-netbeans   File: GitCommitPanel.java   View source code 6 votes vote down vote up
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));
}
 
Example 6
Project: incubator-netbeans   File: UnboundTargetAlert.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Project: etomica   File: DeviceSelector.java   View source code 6 votes vote down vote up
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);
        }
    });
}
 
Example 8
Project: incubator-netbeans   File: NbEditorKit.java   View source code 6 votes vote down vote up
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;
}
 
Example 9
Project: openjdk-jdk10   File: Test4319113.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: AgentWorkbench   File: Distribution.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Project: rapidminer   File: ConfigureDataTableHeader.java   View source code 6 votes vote down vote up
/**
 * @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;
}
 
Example 12
Project: rapidminer   File: InnerOperatorValueCellEditor.java   View source code 6 votes vote down vote up
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);
}
 
Example 13
Project: jmt   File: DefaultsEditor.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 14
Project: jmt   File: DefaultsEditor.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 15
Project: Progetto-C   File: WhiskasPanel.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 16
Project: Laserscan-to-dxf   File: CheckBoxWithText.java   View source code 6 votes vote down vote up
/**
 * 
 */
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);
			}
		}
		
	});
}
 
Example 17
Project: VASSAL-src   File: ColorSwatchConfigurer.java   View source code 6 votes vote down vote up
protected void buildSwatches() {
  if (swatchPanel == null) {
    return;
  }

  if (swatches != null) {
    swatchPanel.remove(swatches);
  }

  ItemListener l = new ItemListener() {
    public void itemStateChanged(ItemEvent evt) {
      updateValue();
    }
  };

  swatches = new SwatchComboBox(l, ((ColorSwatch) value).getConfigureName());
  swatchPanel.add(swatches);

}
 
Example 18
Project: MailCopier   File: SettingsForm.java   View source code 6 votes vote down vote up
private JComboBox<String> get_language_comb() {
    if(language_comb == null) {
        String[] langs = {"Spanish", "English"};
        language_comb = new JComboBox<String>(langs);
        switch(pManager.get_Location()) {
        case "Spanish":
            language_comb.setSelectedItem("Spanish");
            break;
        default:
            language_comb.setSelectedItem("English");
        }
        language_comb.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    if(evt.getStateChange() == ItemEvent.SELECTED) {
                        if(language_banner) {return;}
                        String title = pManager.get_String("warning");
                        String message = pManager.get_String("language_message");
                        boolean sound = pManager.get_sounds_status();
                        Notification.show(title, message, sound, Notification.WARNING_MESSAGE);
                        language_banner = true;
                    }
                }
            });
    }
    return language_comb;
}
 
Example 19
Project: Equella   File: ShowHideComponent.java   View source code 6 votes vote down vote up
public ShowHideComponent(final AbstractButton button, T comp)
{
	this.button = button;
	this.comp = comp;

	button.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent e)
		{
			updateState();
		}
	});

	setLayout(new MigLayout("insets 0, wrap, hidemode 3", "[grow]", "[][grow]"));
	add(button);
	add(comp, "gap indent, grow");

	updateState();
}
 
Example 20
Project: QN-ACTR-Release   File: DefaultsEditor.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 21
Project: Hotel-Properties-Management-System   File: Main_BottomToolbar.java   View source code 6 votes vote down vote up
private ItemListener showWeather() {
    final ItemListener listener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (checkBox.isSelected() == true) {

                final HotelDaoImpl hotelDaoImpl = new HotelDaoImpl();
                final Hotel hotel = hotelDaoImpl.getHotel();
                final String city = liveWeather.getCurrentLocationWeather(hotel.getCity());
                weatherLabel.setEnabled(true);
                weatherLabel.setText(city);

            } else {
                weatherLabel.setEnabled(false);
                weatherLabel.setText("");
            }

        }
    };

    return listener;
}
 
Example 22
Project: Hotel-Properties-Management-System   File: CustomerForm.java   View source code 6 votes vote down vote up
private ItemListener changeTitleListener() {
	final ItemListener listener = new ItemListener() {
		
		@Override
		public void itemStateChanged(ItemEvent e) {
			final String title = titleComboBox.getSelectedItem().toString();
			
			if(title.equalsIgnoreCase("Mr")) {
				genderComboBox.setSelectedIndex(0);
				genderComboBox.revalidate();
				genderComboBox.repaint();
			}
			
			else {
				genderComboBox.setSelectedIndex(1);
				genderComboBox.revalidate();
				genderComboBox.repaint();
			}
		}
	};
	return listener;
}
 
Example 23
Project: JavaGraph   File: RuleTree.java   View source code 6 votes vote down vote up
/**
 * Sets a listener to the anchor image option, if that has not yet been
 * done.
 */
private void setShowAnchorsOptionListener() {
    if (!this.anchorImageOptionListenerSet) {
        JMenuItem showAnchorsOptionItem = getSimulator().getOptions()
            .getItem(Options.SHOW_ANCHORS_OPTION);
        if (showAnchorsOptionItem != null) {
            // listen to the option controlling the rule anchor display
            showAnchorsOptionItem.addItemListener(new ItemListener() {
                @Override
                public void itemStateChanged(ItemEvent e) {
                    suspendListeners();
                    refresh(getSimulatorModel().getState());
                    activateListeners();
                }
            });
            this.anchorImageOptionListenerSet = true;
        }
    }
}
 
Example 24
Project: JavaGraph   File: CheckboxTree.java   View source code 6 votes vote down vote up
/** Constructs a new editor for the enclosing tree. */
public CellEditor(CheckboxTree tree) {
    this.tree = tree;
    this.editor = tree.createRenderer();
    ItemListener itemListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (!CellEditor.this.editor.isInitialising()) {
                stopCellEditing();
                TreeNode editedNode = getInner().getTreeNode();
                editedNode.setSelected(itemEvent.getStateChange() == ItemEvent.SELECTED);
            }
        }
    };
    getInner().getCheckbox().addItemListener(itemListener);
}
 
Example 25
Project: JavaGraph   File: Options.java   View source code 6 votes vote down vote up
/**
 * Adds a checkbox item with a given name to the options, and returns the
 * associated (fresh) menu item.
 * @param name the name of the checkbox menu item to add
 * @return the added {@link javax.swing.JCheckBoxMenuItem}
 */
private final JCheckBoxMenuItem addCheckbox(final String name) {
    JCheckBoxMenuItem result = new JCheckBoxMenuItem(name);
    boolean selected = userPrefs.getBoolean(name, boolOptionDefaults.get(name));
    boolean enabled = isEnabled(name);
    result.setSelected(selected & enabled);
    this.itemMap.put(name, result);
    if (enabled) {
        result.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                userPrefs.putBoolean(name, e.getStateChange() == ItemEvent.SELECTED);
            }
        });
    } else {
        result.setEnabled(false);
    }
    return result;
}
 
Example 26
Project: s-store   File: TableGui.java   View source code 6 votes vote down vote up
private void enableTableOptions()
{
    m_checkLinkCsv.setEnabled(true);
    String sCsvLink = TableEnv.getTableCsvLink(m_lstTblName.getSelectedValue().toString());
    if (sCsvLink != null)
    {
        m_txtLinkCsvPath.setText(CsvLinkStatus.LINKED.m_sStatus + sCsvLink);
        // disable check box listener for one moment
        ItemListener listener = m_checkLinkCsv.getItemListeners()[0];
        m_checkLinkCsv.removeItemListener(listener);
        m_checkLinkCsv.setSelected(true);
        m_checkLinkCsv.addItemListener(listener);
    }
    else
    {
        m_txtLinkCsvPath.setText(CsvLinkStatus.UNLINKED.m_sStatus);
        m_checkLinkCsv.setSelected(false);
    }

    m_txtCardinality.setEnabled(true);
}
 
Example 27
Project: openjdk-jdk10   File: CheckboxOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Checkbox.removeItemListener(ItemListener)} through queue
 */
public void removeItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("removeItemListener") {
        @Override
        public void map() {
            ((Checkbox) getSource()).removeItemListener(itemListener);
        }
    });
}
 
Example 28
Project: incubator-netbeans   File: SearchPatternController.java   View source code 5 votes vote down vote up
/**
 * Bind an abstract button (usually checkbox) to a SearchPattern option.
 *
 * @param option Option whose value the button should represent.
 * @param button Button to control and display the option.
 */
public void bind(@NonNull final Option option,
        @NonNull final AbstractButton button) {
    Parameters.notNull("option", option);                           //NOI18N
    Parameters.notNull("button", button);                           //NOI18N

    if (bindings.containsKey(option)) {
        throw new IllegalStateException(
                "Already binded with option " + option);           // NOI18N
    }

    bindings.put(option, button);
    button.setSelected(getOption(option));
    button.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setOption(option, button.isSelected());
        }
    });
}
 
Example 29
Project: openjdk-jdk10   File: ListOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code List.addItemListener(ItemListener)} through queue
 */
public void addItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("addItemListener") {
        @Override
        public void map() {
            ((List) getSource()).addItemListener(itemListener);
        }
    });
}
 
Example 30
Project: incubator-netbeans   File: PersistenceUnitWizardPanelJdbc.java   View source code 5 votes vote down vote up
public PersistenceUnitWizardPanelJdbc(final Project project, ChangeListener changeListener,
        boolean editName, TableGeneration tg) {
        
    super(project);
    initComponents();
    setTableGeneration(tg);
    libraryCombo.setEnabled(false);
    
    RP.post(new Runnable() {
       @Override
       public void run() {
            PersistenceProviderComboboxHelper comboHelper = new PersistenceProviderComboboxHelper(project);
            comboHelper.connect(libraryCombo);
            libraryCombo.setEnabled(true);
            checkValidity();
       } 
    });

    
    unitNameTextField.setText(Util.getCandidateName(project));
    unitNameTextField.selectAll();
    // unit name editing is not available when adding first PU
    unitNameTextField.setVisible(editName);
    unitNameLabel.setVisible(editName);
    
    DatabaseExplorerUIs.connect(jdbcCombo, ConnectionManager.getDefault());
    jdbcCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            checkValidity();
        }
    });
    
    unitNameTextField.getDocument().addDocumentListener(new ValidationListener());
    errorMessage.setForeground(Color.RED);
            updateWarning();
}
 
Example 31
Project: incubator-netbeans   File: JavaTestCreatorConfiguration.java   View source code 5 votes vote down vote up
private void setupUserInteraction(Callback callback) {
    final ItemListener listener = new CheckBoxListener(callback);

    chkPublic.addItemListener(listener);
    chkProtected.addItemListener(listener);
    chkPackage.addItemListener(listener);
}
 
Example 32
Project: incubator-netbeans   File: WindowSystemBrandingPanel.java   View source code 5 votes vote down vote up
public WindowSystemBrandingPanel(BrandingModel model) {
    super(NbBundle.getMessage(BasicBrandingPanel.class, "LBL_WindowSystemTab"), model); //NOI18N
    
    initComponents();
    refresh();
    enableDisableComponents();
    
    ItemListener listener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setModified();
        }
    };
    cbEnableDnd.addItemListener(listener);
    cbEnableEditorClosing.addItemListener(listener);
    cbEnableFloating.addItemListener(listener);
    cbEnableMaximization.addItemListener(listener);
    cbEnableMinimumSize.addItemListener(listener);
    cbEnableResizing.addItemListener(listener);
    cbEnableSliding.addItemListener(listener);
    cbEnableViewClosing.addItemListener(listener);
    cbEnableAutoSlideInMinimizedMode.addItemListener( listener );
    cbEnableEditorModeDnD.addItemListener( listener );
    cbEnableEditorModeUndocking.addItemListener( listener );
    cbEnableModeClosing.addItemListener( listener );
    cbEnableModeSliding.addItemListener( listener );
    cbEnableViewModeDnD.addItemListener( listener );
    cbEnableViewModeUndocking.addItemListener( listener );
}
 
Example 33
Project: Equella   File: ScriptTab.java   View source code 5 votes vote down vote up
private void setupGui()
{
	nameLabel = new JLabel(s("name"));
	name = new I18nTextField(BundleCache.getLanguages());

	descriptionLabel = new JLabel(s("description"));
	description = new I18nTextArea(BundleCache.getLanguages());
	description.setTextRows(5);

	moveToLive = new JCheckBox(s("move"));
	moveToLive.addItemListener(new ItemListener()
	{
		@Override
		public void itemStateChanged(ItemEvent e)
		{
			enableMoveToLive(moveToLive.isSelected());
		}
	});

	moveToLiveGroup = new ButtonGroup();
	moveToLiveArrival = new JRadioButton(s("move.arrival"));
	moveToLiveAccept = new JRadioButton(s("move.acceptance"));
	moveToLiveGroup.add(moveToLiveArrival);
	moveToLiveGroup.add(moveToLiveAccept);

	proceedNext = new JCheckBox(s("proceed.next"));
	proceedExplanation = new JLabel("<html>" + s("proceed.explanation"));

	scriptLabel = new JLabel(s("scriptlabel"));
	script = new EquellaSyntaxTextArea(100, 200);
	script.addFocusListener(this);
	script.addCaretListener(this);

	statusbar = new JStatusBar(EditorHelper.getStatusBarSpinner());
}
 
Example 34
Project: incubator-netbeans   File: ValueCellEditor.java   View source code 5 votes vote down vote up
public ValueCellEditor() {
    textEditor = new JTextField();
    booleanEditor = new JCheckBox();
    booleanEditor.setOpaque(false);
    booleanEditor.getModel().addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            stopCellEditing();
        }
    });

    booleanLabel = new JCheckBox();
    booleanLabel.setOpaque(false);
    label = new JLabel();
    label.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 5));
}
 
Example 35
Project: Equella   File: GroupBox.java   View source code 5 votes vote down vote up
@Override
public void itemStateChanged(final ItemEvent e)
{
	if( allowSetEnable )
	{
		setAllEnabled(e.getStateChange() == ItemEvent.SELECTED);
	}

	for( final ItemListener listener : listenerList.getListeners(ItemListener.class) )
	{
		listener.itemStateChanged(e);
	}
}
 
Example 36
Project: openjdk-jdk10   File: JComboBoxOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JComboBox.addItemListener(ItemListener)} through queue
 */
public void addItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("addItemListener") {
        @Override
        public void map() {
            ((JComboBox) getSource()).addItemListener(itemListener);
        }
    });
}
 
Example 37
Project: Yass   File: Tap.java   View source code 5 votes vote down vote up
/**
 * Gets the contentPanel attribute of the Tap object
 *
 * @return The contentPanel value
 */
private JPanel getContentPanel() {
    JPanel content = new JPanel(new BorderLayout());
    JTextPane txt = new JTextPane();
    HTMLDocument doc = (HTMLDocument) txt.getEditorKitForContentType("text/html").createDefaultDocument();
    doc.setAsynchronousLoadPriority(-1);
    txt.setDocument(doc);
    URL url = I18.getResource("create_tap.html");
    try {
        txt.setPage(url);
    } catch (Exception ignored) {
    }
    txt.setEditable(false);
    content.add("North", new JScrollPane(txt));

    table = new YassTable();
    table.setEnabled(false);
    content.add("Center", scroll = new JScrollPane(table));
    content.add("South", check = new JCheckBox(I18.get("create_tap_edit")));
    check.setSelected(wizard.getValue("starteditor").equals("true"));
    check.addItemListener(
            new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    if (check.isSelected()) {
                        wizard.setValue("starteditor", "true");
                    } else {
                        wizard.setValue("starteditor", "false");
                    }
                }
            });
    scroll.setPreferredSize(new Dimension(100, 100));
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    return content;
}
 
Example 38
Project: incubator-netbeans   File: HibernateConfigurationWizardPanel.java   View source code 5 votes vote down vote up
/** Creates new form HibernateConfigurationWizardPanel */
public HibernateConfigurationWizardPanel() {
    initComponents();
    setDefaults();
    cmbDbConnection.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            changeSupport.fireChange();
        }

    });
}
 
Example 39
Project: incubator-netbeans   File: QueryParameter.java   View source code 5 votes vote down vote up
public ComboParameter(JComboBox combo, String parameter, String encoding) {
    super(parameter, encoding);
    this.combo = combo;
    combo.setModel(new DefaultComboBoxModel());
    combo.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            fireStateChanged();
        }
    });
    original = (ParameterValue) combo.getSelectedItem();
}
 
Example 40
Project: openjdk-jdk10   File: AbstractButtonOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code AbstractButton.removeItemListener(ItemListener)} through queue
 */
public void removeItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("removeItemListener") {
        @Override
        public void map() {
            ((AbstractButton) getSource()).removeItemListener(itemListener);
        }
    });
}