List of utility methods to do JComboBox
JFileChooser | registerBrowseButtonListener(final JComboBox comboBox, final JButton button, final boolean chooseFile, final boolean isOpen, final FileFilter fileFilter, final File initialDirectory) register Browse Button Listener if (!comboBox.isEditable()) { throw new IllegalArgumentException("The combo box must be editable."); final JFileChooser fileChooser = new JFileChooser(); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { fileChooser.setCurrentDirectory(comboBox.getSelectedItem() == null || comboBox.getSelectedItem().toString().trim().length() == 0 ? initialDirectory ... |
void | removeAllListeners(JComboBox box) remove All Listeners for (ItemListener al : box.getItemListeners()) {
box.removeItemListener(al);
|
void | resetComboBoxInfo(JComboBox reset Combo Box Info if (comboBoxArray.contains(expression)) { jComboBoxField.setSelectedItem(expression); } else { jComboBoxField.setSelectedItem(expression.substring(expression.indexOf(".") + 1, expression.length())); |
void | resetPhaseBox(JComboBox phaseBox) refreshing the drop down to include phases of the selected schema by clearing out the previous items and adding new ones if (!phaseBox.isEnabled()) phaseBox.setEnabled(true); while (phaseBox.getItemCount() != 1) { phaseBox.removeItemAt(phaseBox.getItemCount() - 1); |
void | setColorMenu(JComboBox choice) set Color Menu choice.addItem("BLACK"); choice.addItem("WHITE"); choice.addItem("RED"); choice.addItem("YELLOW"); choice.addItem("GREEN"); choice.addItem("CYAN"); choice.addItem("DARKGRAY"); choice.addItem("LIGHTGRAY"); ... |
void | setComboBoxTheme(JComboBox comboBox) set Combo Box Theme comboBox.setEditable(true); ((JTextField) comboBox.getEditor().getEditorComponent()).setEditable(false); |
void | setErrorBackground(JComboBox comp) set Error Background comp.setBackground(ERROR_BACKGROUND); |
void | setJComboBoxAsHeavyweight(JComboBox combo) set J Combo Box As Heavyweight try { Class cls = Class.forName("javax.swing.PopupFactory"); Field field = cls.getDeclaredField("forceHeavyWeightPopupKey"); if (field != null) { field.setAccessible(true); combo.putClientProperty(field.get(null), Boolean.TRUE); } catch (Exception e1) { ... |
void | setPopupComboChoices(JComboBox aComboBox, String aS) Routine to strip all possible choices from a "popup" string Example of a popup string: "file|socket|ethernet;socket" The | splitted values are the possible combochoices The ; splitted value is the default choice. aComboBox.removeAllItems(); if (aS.length() < 1) { return; String[] stripped = aS.split("\\;"); String defaultChoice = ""; if (stripped.length > 1) { defaultChoice = stripped[1]; ... |
void | setShouldUseAlternSdk(boolean shouldUse, final JCheckBox useAlternativeSdkCB, final JComboBox alternativeSdksComboBox, final JComboBox myModulesComboBox) set Should Use Altern Sdk useAlternativeSdkCB.setSelected(shouldUse); myModulesComboBox.setEnabled(!shouldUse); alternativeSdksComboBox.setEnabled(shouldUse); |