javax.swing.MutableComboBoxModel Java Examples

The following examples show how to use javax.swing.MutableComboBoxModel. 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: PlatformComponentFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns <code>JComboBox</code> containing all suites. Also see
 * {@link #addUserSuite}.
 */
public static JComboBox getSuitesComboBox() {
    MutableComboBoxModel model = new SuiteListModel(userSuites);
    Project[] projects = OpenProjects.getDefault().getOpenProjects();
    for (int i = 0; i < projects.length; i++) {
        String suiteDir = SuiteUtils.getSuiteDirectoryPath(projects[i]);
        if (suiteDir != null) {
            model.addElement(suiteDir);
        }
    }
    JComboBox suiteCombo = new JComboBox(model);
    if (model.getSize() > 0) {
        suiteCombo.setSelectedIndex(0);
    }
    return suiteCombo;
}
 
Example #2
Source File: ActionUtils.java    From jpexs-decompiler with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Insert the given item into the combo box, and set it as first selected
 * item.  If the item already exists, it is removed, so there are no
 * duplicates.
 * @param combo
 * @param item the item to insert. if it's null, then nothing is inserted
 */
public static void insertIntoCombo(JComboBox combo, Object item) {
	if(item == null) {
		return;
	}
	MutableComboBoxModel model = (MutableComboBoxModel) combo.getModel();
	if (model.getSize() == 0) {
		model.insertElementAt(item, 0);
		return;
	}

	Object o = model.getElementAt(0);
	if (o.equals(item)) {
		return;
	}
	model.removeElement(item);
	model.insertElementAt(item, 0);
	combo.setSelectedIndex(0);
}
 
Example #3
Source File: ActionUtils.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Insert the given item into the combo box, and set it as first selected
 * item.  If the item already exists, it is removed, so there are no
 * duplicates.
 * @param combo
 * @param item
 */
public static void insertIntoCombo(JComboBox combo, Object item) {
    MutableComboBoxModel model = (MutableComboBoxModel) combo.getModel();
    if (model.getSize() == 0) {
        model.insertElementAt(item, 0);
        return;
    }

    Object o = model.getElementAt(0);
    if (o.equals(item)) {
        return;
    }
    model.removeElement(item);
    model.insertElementAt(item, 0);
    combo.setSelectedIndex(0);
}
 
Example #4
Source File: SQLHistoryComboBoxModel.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
protected synchronized MutableComboBoxModel duplicateSharedDataModel()
{
	MutableComboBoxModel newModel = new DefaultComboBoxModel();
	for (int i = 0, limit = s_sharedDataModel.getSize(); i < limit; ++i)
	{
		SQLHistoryItem obj = (SQLHistoryItem)s_sharedDataModel.getElementAt(i);
		newModel.addElement(obj.clone());
	} 
	return newModel;
}
 
Example #5
Source File: AbstractSwingGuiCallback.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void replaceBoxModelValues(MutableComboBoxModel<String> mmodel, List<String> newPossibleValues) {
    try {
        while (mmodel.getSize() > 0) {
            mmodel.removeElementAt(0);
        }
    } catch (Exception e) {
        // ignore weird index out of bounds exceptions
    }
    for (String value : newPossibleValues) {
        mmodel.addElement(value);
    }
}
 
Example #6
Source File: AbstractSwingGuiCallback.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void updateComboBoxes(List<FormItem> items) {
    for (FormItem item : items) {
        JComponent field = item.getField();
        if (field instanceof JComboBox) {
            @SuppressWarnings("unchecked")
            JComboBox<String> box = (JComboBox<String>) field;
            List<String> newPossibleValues = item.getPossibleValues();
            if (!boxModelIsSame(box, newPossibleValues)) {
                MutableComboBoxModel<String> mmodel = (MutableComboBoxModel<String>) box.getModel();
                replaceBoxModelValues(mmodel, newPossibleValues);
                mmodel.setSelectedItem(item.getCurrentValue());
            }
        }
    }
}
 
Example #7
Source File: ConfigureExistingProjectPanelVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public MutableComboBoxModel<LocalServer> getLocalServerModel() {
    return null;
}
 
Example #8
Source File: LookAndFeelsComboBox.java    From FlatLaf with Apache License 2.0 4 votes vote down vote up
private MutableComboBoxModel<LookAndFeelInfo> getMutableModel() {
	return (MutableComboBoxModel<LookAndFeelInfo>) getModel();
}
 
Example #9
Source File: LocalServerController.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public MutableComboBoxModel<LocalServer> getLocalServerModel() {
    return localServerComboBoxModel;
}
 
Example #10
Source File: ConfigureNewProjectPanelVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void setLocalServerModel(MutableComboBoxModel<LocalServer> localServers) {
    localServerComponent.setLocalServerModel(localServers);
}
 
Example #11
Source File: ConfigureNewProjectPanelVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public MutableComboBoxModel<LocalServer> getLocalServerModel() {
    return localServerComponent.getLocalServerModel();
}
 
Example #12
Source File: ConfigureExistingProjectPanelVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void setLocalServerModel(MutableComboBoxModel<LocalServer> localServers) {
}
 
Example #13
Source File: LocalServerController.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setLocalServerModel(MutableComboBoxModel<LocalServer> localServers) {
    localServerComboBoxModel = localServers;
    localServerComboBox.setModel(localServerComboBoxModel);
}
 
Example #14
Source File: RunAsLocalWeb.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setLocalServerModel(MutableComboBoxModel<LocalServer> localServers) {
    copyFilesVisual.setLocalServerModel(localServers);
}
 
Example #15
Source File: RunAsLocalWeb.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public MutableComboBoxModel<LocalServer> getLocalServerModel() {
    return copyFilesVisual.getLocalServerModel();
}
 
Example #16
Source File: RunConfigurationPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private MutableComboBoxModel<LocalServer> getLocalServerModel() {
    return (MutableComboBoxModel<LocalServer>) descriptor.getProperty(COPY_SRC_TARGETS);
}
 
Example #17
Source File: ConfigureProjectPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private MutableComboBoxModel<LocalServer> getLocalServers() {
    return (MutableComboBoxModel<LocalServer>) descriptor.getProperty(LOCAL_SERVERS);
}
 
Example #18
Source File: CopyFilesVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setLocalServerModel(MutableComboBoxModel<LocalServer> localServers) {
    localServerController.setLocalServerModel(localServers);
}
 
Example #19
Source File: CopyFilesVisual.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public MutableComboBoxModel<LocalServer> getLocalServerModel() {
    return localServerController.getLocalServerModel();
}
 
Example #20
Source File: ConfigurableProjectPanel.java    From netbeans with Apache License 2.0 votes vote down vote up
public abstract void setLocalServerModel(MutableComboBoxModel<LocalServer> localServers); 
Example #21
Source File: ConfigurableProjectPanel.java    From netbeans with Apache License 2.0 votes vote down vote up
public abstract MutableComboBoxModel<LocalServer> getLocalServerModel();