Java 类javax.swing.MutableComboBoxModel 实例源码

项目:incubator-netbeans    文件:PlatformComponentFactory.java   
/**
 * 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;
}
项目:geoxygene    文件:OGCFilterPanel.java   
/**
 * Update the methods list stored in {@code this} according to the current
 * selected class in the cbClasses combo box.
 */
public void changeSelectedClass(Class<?> selectedClass) {
  this.filteredClass = selectedClass;
  this.methodsList.clear();
  Collection<Class<?>> types = new HashSet<Class<?>>();
  types.add(long.class);
  types.add(String.class);
  types.add(double.class);
  types.add(int.class);
  types.add(boolean.class);
  types.add(float.class);
  this.methodsList.addAll(ReflectionUtil.getAllGetters(filteredClass, types));
  MutableComboBoxModel cbModel = new DefaultComboBoxModel();
  for (int i = 0; i < this.methodsList.size(); i++) {
    cbModel.addElement(
        this.methodsList.get(i).getName().replaceFirst("get", ""));
  }
  System.out.println(methodsList);
  this.cbMethods.setModel(cbModel);
  this.parent.pack();
}
项目:ezrlc    文件:RectPlotAddMeasurementWindow.java   
/**
 * Sets the drop combo box items of the model list
 * 
 * @param modelIDs
 *            id array
 */
public void setModels(int[] modelIDs) {
    String[] modelNames = new String[modelIDs.length];
    for (int i = 0; i < modelIDs.length; i++) {
        modelNames[i] = "Model " + modelIDs[i];
        // cbModelList.addItem(modelNames[i]);
    }

    MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) cbModelList.getModel();
    cbModelList.removeAllItems();
    for (int i = 0; i < model.getSize(); i++) {
        model.removeElementAt(i);
    }

    for (int i = 0; i < modelIDs.length; i++) {
        cbModelList.addItem(modelNames[i]);
        btnOk.setEnabled(true);
        rdbtnCompare.setEnabled(true);
        rdbtnModel.setEnabled(true);
    }
    resetButtons();
}
项目:ezrlc    文件:SmithChartAddMeasurementWindow.java   
/**
 * Sets the drop combo box items of the model list
 * 
 * @param modelIDs
 *            ids
 */
public void setModels(int[] modelIDs) {
    String[] modelNames = new String[modelIDs.length];
    for (int i = 0; i < modelIDs.length; i++) {
        modelNames[i] = "Model " + modelIDs[i];
        // cbModelList.addItem(modelNames[i]);
    }

    MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) cbModelList.getModel();
    cbModelList.removeAllItems();
    for (int i = 0; i < model.getSize(); i++) {
        model.removeElementAt(i);
    }

    for (int i = 0; i < modelIDs.length; i++) {
        cbModelList.addItem(modelNames[i]);
        rdbtnModel.setEnabled(true);
        btnOk.setEnabled(true);
    }
    rdbtnFile.setSelected(true);
    rdbtnModel.setSelected(false);
}
项目:triplea    文件:SelectAndViewEditor.java   
/**
 * Sets the bean on this editor.
 * If an editor of the same class is found, it is selected an modified to match
 * If no bean of this type is found, it is added to the list
 *
 * @param bean the bean
 */
public void setSelectedBean(final IBean bean) {
  final MutableComboBoxModel<IBean> model = (MutableComboBoxModel<IBean>) selector.getModel();
  final DefaultComboBoxModel<IBean> newModel = new DefaultComboBoxModel<>();
  boolean found = false;
  for (int i = 0; i < model.getSize(); i++) {
    final IBean candidate = model.getElementAt(i);
    if (candidate.equals(bean)) {
      found = true;
      newModel.addElement(bean);
    } else {
      newModel.addElement(candidate);
    }
  }
  if (found) {
    selector.setModel(newModel);
  } else {
    model.addElement(bean);
  }
  selector.setSelectedItem(bean);
  updateView();
}
项目:jpexs-decompiler    文件:ActionUtils.java   
/**
 * 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);
}
项目:bigtable-sql    文件:SQLHistoryComboBoxModel.java   
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;
}
项目:swingx    文件:TitledPanelDemo.java   
private ComboBoxModel createFontModel() {
    MutableComboBoxModel model = new DefaultComboBoxModel();
    // <snip> JXTitledPanel configure title properties
    // Font options (based on default)
    Font baseFont = UIManager.getFont("JXTitledPanel.titleFont");
    model.addElement(new DisplayInfo<Font>("Default ", baseFont));
    Font italicFont = new FontUIResource(baseFont.deriveFont(Font.ITALIC));
    model.addElement(new DisplayInfo<Font>("Derived (Italic)" , italicFont));
    Font bigFont = new FontUIResource(baseFont.deriveFont(baseFont.getSize2D() * 2));
    model.addElement(new DisplayInfo<Font>("Derived (Doubled Size) ", bigFont));
    // </snip>
    return model;
}
项目:swingx    文件:TitledPanelDemo.java   
private ComboBoxModel createBackgroundModel() {
    MutableComboBoxModel model = new DefaultComboBoxModel();
    // <snip> JXTitledPanel configure title properties
    // Background Painter options 
    Painter<?> baseFont =  (Painter<?>) UIManager.get("JXTitledPanel.titlePainter");
    model.addElement(new DisplayInfo<Painter<?>>("Default ", baseFont));
    model.addElement(new DisplayInfo<Painter<?>>("Checkerboard", 
            new PainterUIResource<JComponent>(new CheckerboardPainter())));
    // PENDING JW: add more options - image, gradient, animated... 
    // </snip>
    return model;
}
项目:metasfresh    文件:MutableComboBoxModelProxy.java   
private final MutableComboBoxModel getDelegateToUse()
{
    if (delegate == null)
    {
        return COMBOBOXMODEL_NULL;
    }
    return delegate;
}
项目:power-matchmaker    文件:ProjectEditor.java   
public void actionPerformed(ActionEvent e) {
    SQLTable sourceTable = (SQLTable)sourceChooser.getTableComboBox().getSelectedItem();
    if (sourceTable == null) {
        JOptionPane.showMessageDialog(panel,
                "You have to select a source table and save before picking columns" );
        return;
    }
    try {
        for(SQLColumn c : sourceTable.getColumns()) {
            c.setType(swingSession.getSQLType(c.getType()));
        }
    } catch (SQLObjectException evt) {
        throw new RuntimeException(evt);
    }
    try {
        MatchMakerIndexBuilder indexBuilder = new MatchMakerIndexBuilder(sourceTable, (MutableComboBoxModel)indexComboBox.getModel(),swingSession);
        JDialog d = DataEntryPanelBuilder.createDataEntryPanelDialog(
                indexBuilder,
                getParentWindow(),
                "Choose the index",
                "OK");
        d.pack();
        d.setLocationRelativeTo(swingSession.getFrame());
        d.setVisible(true);

    } catch (Exception ex) {
        ex.printStackTrace();
        SPSUtils.showExceptionDialogNoReport(panel, "An exception occured while picking columns", ex);
    }
}
项目:OTCAnalyser    文件:SaveWindow.java   
static void updateLoad() {
    Object [] strings;
    try {
        LinkedHashMap<String,Search> savedSearches = (LinkedHashMap<String,Search>) Database.getSavedSearches();
        strings = (savedSearches.keySet()).toArray();
        MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) Loadbox.getModel();
        ((DefaultComboBoxModel<String>) model).removeAllElements();
        for (Object i:strings) {
            model.addElement((String) i);
        }
    }
    catch (NullPointerException e) {
    }
}
项目:OTCAnalyser    文件:AssetChange.java   
public void updateAssetClass() {
    tax.settlementType.setVisible(false);
    String selectedAsset = (String) tax.Asset.getSelectedItem();
    String[] AssetBaseClasses={""};
    switch (selectedAsset) {
        case ("Credit"): 
            AssetBaseClasses = TextStrings.CreditBaseProducts;
            break;
        case ("Interest"):
            AssetBaseClasses = TextStrings.InterestBaseProducts;
            break;
        case ("Commodity"):
            AssetBaseClasses = TextStrings.CommodityBaseProducts;
            tax.settlementType.setVisible(true);
            break;
        case ("Foreign Exchange"):
        AssetBaseClasses = TextStrings.ForexBaseProducts;
            break;
        case ("Equity"):
            AssetBaseClasses = TextStrings.EquityBaseProducts;
            break;
        default:break;
    }
    TaxonomySelector.baseClassflag = false;
    MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) tax.BaseClass.getModel();
    ((DefaultComboBoxModel<String>) model).removeAllElements();
    for (String i:AssetBaseClasses) {
        model.addElement(i);
    }
    TaxonomySelector.baseClassflag = true;
    tax.baseProductChange.updateBaseClass();
}
项目:findbugs-all-the-bugs    文件:AbstractSwingGuiCallback.java   
private void updateComboBoxes(List<FormItem> items) {
    for (FormItem item : items) {
        JComponent field = item.getField();
        if (field instanceof JComboBox) {
            JComboBox box = (JComboBox) field;
            List<String> newPossibleValues = item.getPossibleValues();
            if (!boxModelIsSame(box, newPossibleValues)) {
                MutableComboBoxModel mmodel = (MutableComboBoxModel) box.getModel();
                replaceBoxModelValues(mmodel, newPossibleValues);
                mmodel.setSelectedItem(item.getCurrentValue());
            }
        }
    }
}
项目:findbugs-all-the-bugs    文件:AbstractSwingGuiCallback.java   
private void replaceBoxModelValues(MutableComboBoxModel 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);
    }
}
项目:metasfresh    文件:MutableComboBoxModelProxy.java   
public MutableComboBoxModelProxy(final MutableComboBoxModel delegate)
{
    super();
    setDelegate(delegate);
}
项目:power-matchmaker    文件:MatchMakerIndexBuilder.java   
public MatchMakerIndexBuilder(final SQLTable table, final MutableComboBoxModel indexModel, final MatchMakerSwingSession swingSession) throws SQLObjectException {
    this.table = table;
    this.indexModel = indexModel;
    this.swingSession = swingSession;

    final SQLIndex oldIndex = (SQLIndex)indexModel.getSelectedItem();

    if (oldIndex != null &&
            table.getIndexByName(oldIndex.getName()) == null) {
        oldName = oldIndex.getName();
    } else {
        for( int i=0; ;i++) {
            oldName = table.getName()+"_UPK"+(i==0?"":String.valueOf(i));
            if (table.getIndexByName(oldName) == null) break;
        }
    }

    columnChooserTableModel = new ColumnChooserTableModel(table, oldIndex, true);
    final EditableJTable columntable = new EditableJTable(columnChooserTableModel);
    columntable.addColumnSelectionInterval(1, 1);
    TableUtils.fitColumnWidths(columntable, 15);

    FormLayout layout = new FormLayout(
            "4dlu,fill:pref:grow,4dlu",
    //column 1    2              3
            "10dlu,pref:grow,4dlu,pref:grow,4dlu,pref:grow,10dlu,fill:min(200dlu;pref):grow,4dlu");
    //row    1     2         3    4         5    6         7     8                          9    10   11

    panel = logger.isDebugEnabled() ? new FormDebugPanel(layout)
            : new JPanel(layout);
    PanelBuilder pb = new PanelBuilder(layout, panel);

    CellConstraints cc = new CellConstraints();

    statusComponent = new StatusComponent();
       pb.add(statusComponent, cc.xy(2, 2));
    pb.add(new JLabel("Table: " + DDLUtils.toQualifiedName(table)),
                cc.xy(2, 4));
    indexName = new JTextField(oldName,15);
    pb.add(indexName, cc.xy(2, 6));
    JScrollPane scrollPane = new JScrollPane(columntable);
       pb.add(scrollPane, cc.xy(2, 8, "f,f"));

       validationHandler = new FormValidationHandler(statusComponent);
    validationHandler.addValidateObject(indexName,
               new RegExValidator(
                       "[a-z_][a-z0-9_]*",
                       "Index name must be a valid SQL identifier",
                       false));
}
项目:OTCAnalyser    文件:BaseProductChange.java   
public void updateBaseClass() {
    String selectedBaseClass = (String) tax.BaseClass.getSelectedItem();
    String[] subClasses={"n/a"};
    switch (selectedBaseClass) {
        case ("Single Name"): subClasses = TextStrings.CreditSingleNameSubProducts;
            break;
        case ("Index Tranche"): subClasses = TextStrings.CreditIndexTrancheSubProducts;
            break;
        case ("Index"): subClasses = TextStrings.CreditIndexSubProducts;
            break;
        case ("Swaptions"): subClasses = TextStrings.CreditSwaptionsSubProducts;
            break;
        case ("Exotic"):
            if (tax.Asset.getSelectedItem() == "Credit") subClasses = TextStrings.CreditExoticSubProducts;
            break;
        case ("IR Swap"): subClasses = TextStrings.InterestIRSwapSubProducts;
            break;
        case ("Cross Currency"): subClasses = TextStrings.InterestCrossCurrencySubProducts;
            break;
        case ("Option"):
            if (tax.Asset.getSelectedItem() == "Interest") subClasses =  TextStrings.InterestOptionSubProducts;
            else subClasses = TextStrings.EquityOptionSubProducts;
            break;
        case ("Metals"): subClasses = TextStrings.CommodityMetalsSubProducts;
            break;
        case ("Energy"): subClasses = TextStrings.CommodityEnergySubProducts;
            break;
        case ("Agriculture"): subClasses = TextStrings.CommodityAgricultureSubProducts;
            break;
        case ("Environmental"): subClasses = TextStrings.CommodityEnvironmentalSubProducts;
            break;
        case ("Simple Exotic"): subClasses = TextStrings.ForexSimpleExoticSubProducts;
            break;
        case ("Swap"): subClasses = TextStrings.EquitySwapSubProducts;
            break;
        case ("Portfolio swap"): subClasses = TextStrings.EquityPortfolioSwapSubProducts;
            break;
        case ("Contract for difference"): subClasses = TextStrings.EquityContractForDifferenceSubProducts;
            break;
        case ("Forward"): subClasses = TextStrings.EquityForwardSubProducts;
            break;
        default:break;
    }
    MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) tax.SubClass.getModel();
    ((DefaultComboBoxModel<String>) model).removeAllElements();
    for (String i:subClasses) {
        model.addElement(i);
    }
}