类javax.swing.ComboBoxModel源码实例Demo

下面列出了怎么用javax.swing.ComboBoxModel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openprodoc   文件: TCImportFold.java
private ComboBoxModel getListObjDoc()
{
Vector VObjects=new Vector();
try {
DriverGeneric Session=MainWin.getSession();
PDObjDefs Obj = new PDObjDefs(Session);
Cursor CursorId = Obj.getListDocs();
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    Attribute Attr=Res.getAttr(PDObjDefs.fNAME);
    VObjects.add(Attr.getValue());
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
} catch (PDException ex)
    {
    MainWin.Message("Error"+ex.getLocalizedMessage());
    }
return(new DefaultComboBoxModel(VObjects));
}
 
private void updatePackages() {
    final Object item = createdLocationComboBox.getSelectedItem();
    if (!(item instanceof SourceGroupSupport.SourceGroupProxy)) {
        return;
    }
    WAIT_MODEL.setSelectedItem(createdPackageComboBox.getEditor().getItem());
    createdPackageComboBox.setModel(WAIT_MODEL);

    if (updatePackagesTask != null) {
        updatePackagesTask.cancel();
    }

    updatePackagesTask = new RequestProcessor("ComboUpdatePackages").post(new Runnable() { // NOI18N
        @Override
        public void run() {
            final ComboBoxModel model = ((SourceGroupSupport.SourceGroupProxy) item).getPackagesComboBoxModel();
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    model.setSelectedItem(createdPackageComboBox.getEditor().getItem());
                    createdPackageComboBox.setModel(model);
                }
            });
        }
    });
}
 
源代码3 项目: openprodoc   文件: MantTaskEvents.java
private ComboBoxModel getListObjDoc()
{
Vector VObjects=new Vector();
try {
DriverGeneric Session=MainWin.getSession();
PDObjDefs Obj = new PDObjDefs(Session);
Cursor CursorId = Obj.getListDocs();
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    Attribute Attr=Res.getAttr(PDObjDefs.fNAME);
    VObjects.add(Attr.getValue());
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
} catch (PDException ex)
    {
    MainWin.Message("Error"+ex.getLocalizedMessage());
    }
return(new DefaultComboBoxModel(VObjects));
}
 
源代码4 项目: openprodoc   文件: MantTaskEvents.java
private ComboBoxModel getListObjFold()
{
Vector VObjects=new Vector();
try {
DriverGeneric Session=MainWin.getSession();
PDObjDefs Obj = new PDObjDefs(Session);
Cursor CursorId = Obj.getListFold();
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    Attribute Attr=Res.getAttr(PDObjDefs.fNAME);
    VObjects.add(Attr.getValue());
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
} catch (PDException ex)
    {
    MainWin.Message("Error"+ex.getLocalizedMessage());
    }
return(new DefaultComboBoxModel(VObjects));
}
 
public AutoCompletionComboBox(boolean caseSensitive, int preferredWidth, int preferredHeight, boolean wide,
		ComboBoxModel<E> model) {
	super(preferredWidth, preferredHeight, wide, model);

	this.caseSensitive = caseSensitive;

	setEditable(true);
	setEditor(getEditor());

	addFocusListener(new FocusAdapter() {

		@Override
		public void focusLost(FocusEvent e) {
			setSelectedItem(((JTextField) getEditor().getEditorComponent()).getText());
			actionPerformed(new ActionEvent(this, 0, "editingStopped"));
		}
	});
}
 
源代码6 项目: netbeans   文件: ShowEffPomDiffPanel.java
/**
 * Creates new form ShowEffPomDiffPanel
 */
public ShowEffPomDiffPanel(ProjectConfigurationProvider<MavenConfiguration> configs) {
    initComponents();
    ComboBoxModel<MavenConfiguration> model = new DefaultComboBoxModel<MavenConfiguration>(configs.getConfigurations().toArray(new MavenConfiguration[0]));
    comConfiguration.setModel(model);
    comConfiguration.setEditable(false);
    comConfiguration.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            return super.getListCellRendererComponent(list, ((ProjectConfiguration)value).getDisplayName(), index, isSelected, cellHasFocus);
        }
    });
    comConfiguration.setSelectedItem(configs.getActiveConfiguration());
    enableFields();
    epProperties.setContentType("text/x-properties");
}
 
源代码7 项目: netbeans   文件: FindUsagesDialogOperator.java
/**
 * Select the scope
 *
 * @param projectName The name of project or null if find should be
 * performed on all projects
 */
public void setScope(String projectName) {
    JComboBoxOperator scopeOperator = getScope();
    String select_item;
    if (projectName == null) {
        select_item = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.java.ui.scope.Bundle", "LBL_AllProjects");
    } else {
        select_item = projectName;
    }

    ComboBoxModel model = scopeOperator.getModel();
    int index = -1;
    String dn;
    for (int i = 0; i < model.getSize()-1; i++) { /// -1 ... it's custom and it fails
        dn = ((org.netbeans.modules.refactoring.spi.impl.DelegatingScopeProvider) model.getElementAt(i)).getDisplayName();
        if (dn.indexOf(select_item) != -1) {
            index = i;
        }
    }
    scopeOperator.selectItem(index);
}
 
源代码8 项目: netbeans   文件: SettingsPanel.java
/**
 * Selects a given template.
 *
 * @param  templatePath  path of the template which should be selected;
 *                       may be <code>null</code> - then no item is selected
 */
void selectTemplate(String templatePath) {
    if (templatePath == null) {
        return;
    }
    
    ComboBoxModel model = cboTemplate.getModel();
    int itemsCount = model.getSize();
    
    if (itemsCount == 0) {
        return;
    }
    
    for (int i = 0; i < itemsCount; i++) {
        NamedObject namedObj = (NamedObject) model.getElementAt(i);
        FileObject template = (FileObject) namedObj.object;
        if (template.getPath().equals(templatePath)) {
            cboTemplate.setSelectedIndex(i);
            return;
        }
    }
}
 
源代码9 项目: openprodoc   文件: MantTaskCron.java
private ComboBoxModel getListObjDoc()
{
Vector VObjects=new Vector();
try {
DriverGeneric Session=MainWin.getSession();
PDObjDefs Obj = new PDObjDefs(Session);
Cursor CursorId = Obj.getListDocs();
Record Res=Session.NextRec(CursorId);
while (Res!=null)
    {
    Attribute Attr=Res.getAttr(PDObjDefs.fNAME);
    VObjects.add(Attr.getValue());
    Res=Session.NextRec(CursorId);
    }
Session.CloseCursor(CursorId);
} catch (PDException ex)
    {
    MainWin.Message("Error"+ex.getLocalizedMessage());
    }
return(new DefaultComboBoxModel(VObjects));
}
 
源代码10 项目: quickfix-messenger   文件: FieldPanel.java
private void setValue(String value)
{
	if (fieldComboBox != null)
	{
		ComboBoxModel<FieldValue> comboBoxModel = fieldComboBox.getModel();
		for (int i = 0; i < comboBoxModel.getSize(); i++)
		{
			FieldValue fieldValue = comboBoxModel.getElementAt(i);
			if (fieldValue.getEnumValue().equals(value))
			{
				fieldComboBox.setSelectedIndex(i);
			}
		}
	}

	else
	{
		fieldTextField.setText(value);
	}
}
 
源代码11 项目: swingsane   文件: KnownSaneOptions.java
public static ComboBoxModel<String> getSourceModel(Scanner scanner) {
  DefaultComboBoxModel<String> sourceModel = new DefaultComboBoxModel<String>();

  HashMap<String, StringOption> stringOptions = scanner.getStringOptions();

  StringOption stringOption = stringOptions.get(SANE_NAME_SCAN_SOURCE);

  if (stringOption == null) {
    return null;
  }

  Constraints constraints = stringOption.getConstraints();
  List<String> values = constraints.getStringList();

  for (String value : values) {
    sourceModel.addElement(value);
  }

  if (values.size() > 0) {
    return sourceModel;
  } else {
    return null;
  }
}
 
private ComboBoxModel createRemoteBranchDropdownModel() {
    final SortedComboBoxModel<GitRemoteBranch> sortedRemoteBranches
            = new SortedComboBoxModel<GitRemoteBranch>(new TfGitHelper.BranchComparator());
    final GitRemoteBranch remoteTrackingBranch = this.getRemoteTrackingBranch();

    // only show valid remote branches
    sortedRemoteBranches.addAll(Collections2.filter(getInfo().getRemoteBranches(),
            remoteBranch -> {
                /* two conditions:
                 *   1. remote must be a vso/tfs remote
                 *   2. this isn't the remote tracking branch of current local branch
                 */
                return tfGitRemotes.contains(remoteBranch.getRemote())
                        && !remoteBranch.equals(remoteTrackingBranch);
            })
    );
    sortedRemoteBranches.setSelectedItem(TfGitHelper.getDefaultBranch(sortedRemoteBranches.getItems(), tfGitRemotes));

    return sortedRemoteBranches;
}
 
源代码13 项目: zap-extensions   文件: AjaxSpiderExplorer.java
public void optionsLoaded(QuickStartParam quickStartParam) {
    getSelectCheckBox().setSelected(quickStartParam.isAjaxSpiderEnabled());
    String def = quickStartParam.getAjaxSpiderDefaultBrowser();
    if (def == null || def.length() == 0) {
        // no default
        return;
    }
    ComboBoxModel<ProvidedBrowserUI> model = this.getBrowserComboBox().getModel();
    for (int idx = 0; idx < model.getSize(); idx++) {
        ProvidedBrowserUI el = model.getElementAt(idx);
        if (el.getName().equals(def)) {
            model.setSelectedItem(el);
            break;
        }
    }
}
 
public void addLocalRepositoryFolderIfMissing(LocalRepositoryFolder localRepositoryFolder) {
    ComboBoxModel<LocalRepositoryFolder> foldersModel = this.foldersComboBox.getModel();
    boolean foundFolder = false;
    for (int i = 0; i < foldersModel.getSize() && !foundFolder; i++) {
        LocalRepositoryFolder existingFolder = foldersModel.getElementAt(i);
        if (existingFolder != null && existingFolder.getId() == localRepositoryFolder.getId()) {
            foundFolder = true;
        }
    }
    if (!foundFolder) {
        if (foldersModel.getSize() == 0) {
            this.foldersComboBox.addItem(null);
        }
        this.foldersComboBox.addItem(localRepositoryFolder);
    }
}
 
源代码15 项目: snap-desktop   文件: ColorPaletteChooser.java
public Range getRangeFromFile() {
    final ComboBoxModel<ColorPaletteWrapper> model = getModel();
    final int selectedIndex = getSelectedIndex();
    final ColorPaletteWrapper paletteWrapper = model.getElementAt(selectedIndex);
    String name = paletteWrapper.name;
    final ColorPaletteDef cpd;
    if (name.startsWith(DERIVED_FROM)) {
        name = name.substring(DERIVED_FROM.length()).trim();
        if (name.toLowerCase().endsWith(".cpd")) {
            name = FileUtils.getFilenameWithoutExtension(name);
        }
        cpd = findColorPalette(name);
    } else {
        cpd = paletteWrapper.cpd;
    }
    return new Range(cpd.getMinDisplaySample(), cpd.getMaxDisplaySample());
}
 
源代码16 项目: pentaho-reporting   文件: RepositoryOpenDialog.java
public void setSelectedView( final FileObject selectedView ) {
  this.selectedView = selectedView;
  if ( selectedView != null ) {
    logger.debug( "Setting selected view to " + selectedView );
    try {
      if ( selectedView.getType() == FileType.FILE ) {
        logger.debug( "Setting filename in selected view to " + selectedView.getName().getBaseName() );
        this.fileNameTextField.setText( URLDecoder.decode( selectedView.getName().getBaseName(), "UTF-8" ) );
      }
    } catch ( Exception e ) {
      // can be ignored ..
      logger.debug( "Unable to determine file type. This is not fatal.", e );
    }
    final ComboBoxModel comboBoxModel = createLocationModel( selectedView );
    this.locationCombo.setModel( comboBoxModel );
    this.table.setSelectedPath( (FileObject) comboBoxModel.getSelectedItem() );
  } else {
    this.fileNameTextField.setText( null );
    this.table.setSelectedPath( null );
    this.locationCombo.setModel( new DefaultComboBoxModel() );
  }
}
 
源代码17 项目: netbeans   文件: CopyDialogTest.java
private void assertModel (Map<String, String> items, JComboBox combo, List<String> expected) {
    ComboBoxModel model = combo.getModel();
    assertEquals(expected.size() / 2, model.getSize());
    for (int i = 0; i < model.getSize(); ++i) {
        assertEquals(expected.get(i * 2), model.getElementAt(i));
        assertEquals(expected.get(i * 2 + 1), items.get((String) model.getElementAt(i)));
    }
}
 
源代码18 项目: openAGV   文件: SelectionPropertyEditorPanel.java
@Override // DetailsDialogContent
public void setProperty(Property property) {
  fProperty = (AbstractProperty) property;

  @SuppressWarnings("unchecked")
  ComboBoxModel<Object> model
      = new DefaultComboBoxModel<>(((Selectable<Object>) fProperty).getPossibleValues().toArray());
  valueComboBox.setModel(model);

  Object value = fProperty.getValue();
  valueComboBox.setSelectedItem(value);
  valueComboBox.setRenderer(listCellRenderer);
}
 
源代码19 项目: pcgen   文件: PrintPreviewDialog.java
private static ComboBoxModel<String> createPagesModel(int pages)
{
	String[] pageNumbers = new String[pages];
	for (int i = 0; i < pages; i++)
	{
		pageNumbers[i] = (i + 1) + " of " + pages;
	}
	return new DefaultComboBoxModel<>(pageNumbers);
}
 
源代码20 项目: bigtable-sql   文件: UpdateSummaryTable.java
private void setModel(JComboBox box, ArtifactAction... actions) {
	ComboBoxModel oldModel = box.getModel();
	box.setModel(getComboBoxModel(actions));
	if (oldModel.getSize() != actions.length) {
		box.firePropertyChange("itemCount", oldModel.getSize(), actions.length);
	}
}
 
源代码21 项目: swingsane   文件: ComponentController.java
private void updateSourceModel(ComboBoxModel<String> sourceModel, String source) {
  JComboBox<String> sourceComboBox = components.getSourceComboBox();
  sourceComboBox.setModel(sourceModel != null ? sourceModel : new DefaultComboBoxModel<String>());
  sourceComboBox.setEnabled(sourceModel != null ? true : false);
  if (source != null) {
    sourceComboBox.setSelectedItem(source);
  }
}
 
源代码22 项目: netbeans   文件: ModifyElementRulesPanel.java
private ComboBoxModel createSelectorModel() {
    HtmlModel model = HtmlModelFactory.getModel(HtmlVersion.HTML5);
    Collection<String> tagNames = new ArrayList<>();
    tagNames.add(null);
    for (HtmlTag tag : model.getAllTags()) {
        tagNames.add(tag.getName());
    }
    return new DefaultComboBoxModel(tagNames.toArray());

}
 
源代码23 项目: netbeans   文件: ModifyElementRulesPanel.java
private ComboBoxModel createIdsModel() {
    Collection<String> ids = new ArrayList<>();
    ids.add(null);
    FileObject selectedStyleSheet = (FileObject) styleSheetCB.getSelectedItem();
    if (selectedStyleSheet != null) {
        Collection<String> foundInFile = files2ids.get(selectedStyleSheet);
        if (foundInFile != null) {
            ids.addAll(foundInFile);
        }
    }
    return new DefaultComboBoxModel(ids.toArray());
}
 
源代码24 项目: nextreports-designer   文件: DesignerTablePanel.java
private boolean hasEmpty(ComboBoxModel model) {
	int size = model.getSize();
	for (int i=0; i<size; i++) {
		if ("".equals(model.getElementAt(i))) {
			return true;
		}
	}
	return false;
}
 
源代码25 项目: netbeans   文件: EntityClassesPanel.java
private void updatePackageComboBox() {
    SourceGroup sourceGroup = (SourceGroup)locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
源代码26 项目: netbeans   文件: DBScriptPanel.java
private void updatePackageComboBox() {
    SourceGroup sourceGroup = (SourceGroup) locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem() != null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
源代码27 项目: pentaho-reporting   文件: PlainTextExportDialog.java
/**
 * Sets the characters per inch.
 *
 * @param cpi
 *          the characters per inch.
 */
public void setCharsPerInch( final float cpi ) {
  final Float cpiObj = new Float( cpi );
  final ComboBoxModel model = cbCharsPerInch.getModel();
  for ( int i = 0; i < model.getSize(); i++ ) {
    if ( cpiObj.equals( model.getElementAt( i ) ) ) {
      cbCharsPerInch.setSelectedIndex( i );
      return;
    }
  }
  throw new IllegalArgumentException( messages.getErrorString( "PlainTextExportDialog.ERROR_0002_NO_SUCH_CPI", String
      .valueOf( cpi ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
 
源代码28 项目: rapidminer-studio   文件: DataEditor.java
@SuppressWarnings("unchecked")
public ValueTypeCellEditor(final int valueType) {
	super(new JComboBox<String>());
	ComboBoxModel<String> model = new DefaultComboBoxModel<String>() {

		private static final long serialVersionUID = 914764579359633239L;

		private String[] valueTypes = new String[VALUE_TYPE_OPTIONS[valueType].length];
		{
			for (int i = 0; i < VALUE_TYPE_OPTIONS[valueType].length; i++) {
				valueTypes[i] = Ontology.ATTRIBUTE_VALUE_TYPE.mapIndex(VALUE_TYPE_OPTIONS[valueType][i]);
			}
		}

		@Override
		public String getElementAt(int index) {
			return valueTypes[index];
		}

		@Override
		public int getSize() {
			return valueTypes.length;
		}
	};
	((JComboBox<?>) super.getComponent()).setEnabled(editValueTypes);
	((JComboBox<String>) super.getComponent()).setModel(model);
}
 
源代码29 项目: pcgen   文件: PrintPreviewDialog.java
@Override
protected void done()
{
	try
	{
		ComboBoxModel<Object> model = new DefaultComboBoxModel<>(get());
		model.setSelectedItem(null);
		sheetBox.setModel(model);
	}
	catch (InterruptedException | ExecutionException ex)
	{
		Logging.errorPrint("could not load sheets", ex);
	}
}
 
源代码30 项目: openjdk-jdk9   文件: JComboBoxOperator.java
/**
 * Maps {@code JComboBox.getModel()} through queue
 */
public ComboBoxModel<?> getModel() {
    return (runMapping(new MapAction<ComboBoxModel<?>>("getModel") {
        @Override
        public ComboBoxModel<?> map() {
            return ((JComboBox) getSource()).getModel();
        }
    }));
}
 
 类所在包
 同包方法