本文整理汇总了Java中javax.swing.DefaultComboBoxModel.getElementAt方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultComboBoxModel.getElementAt方法的具体用法?Java DefaultComboBoxModel.getElementAt怎么用?Java DefaultComboBoxModel.getElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultComboBoxModel
的用法示例。
在下文中一共展示了DefaultComboBoxModel.getElementAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToModel
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void addToModel (final Revision newItem, final JComboBox cmbDiffTree) {
DefaultComboBoxModel model = (DefaultComboBoxModel) cmbDiffTree.getModel();
for (int i = 0; i < model.getSize(); ++i) {
final Object item = model.getElementAt(i);
if (item instanceof Revision && ((Revision) item).getCommitId().equals(newItem.getCommitId())
&& ((Revision) item).getRevision().equals(newItem.getRevision())) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
cmbDiffTree.setSelectedItem(item);
}
});
return;
}
}
model.addElement(newItem);
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
cmbDiffTree.setSelectedItem(newItem);
}
});
}
示例2: getSelectedRCIntern
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
RepositoryConnection getSelectedRCIntern() {
String urlString;
try {
urlString = getUrlString();
}
catch (InterruptedException ex) {
// should not happen
Subversion.LOG.log(Level.SEVERE, null, ex);
return null;
}
DefaultComboBoxModel dcbm = (DefaultComboBoxModel) repositoryPanel.urlComboBox.getModel();
int idx = dcbm.getIndexOf(urlString);
if(idx > -1) {
return (RepositoryConnection) dcbm.getElementAt(idx);
}
return getEditedRC();
}
示例3: btnProjectActionPerformed
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void btnProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProjectActionPerformed
JFileChooser chooser = ProjectChooser.projectChooser();
int res = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this));
if (res == JFileChooser.APPROVE_OPTION) {
File fil = chooser.getSelectedFile();
FileObject fo = FileUtil.toFileObject(fil);
if (fo != null) {
try {
Project p = ProjectManager.getDefault().findProject(fo);
DefaultComboBoxModel model = (DefaultComboBoxModel)comProject.getModel();
model.addElement(p);
model.setSelectedItem(p);
if (EMPTY == model.getElementAt(0)) {
model.removeElement(EMPTY);
}
} catch (IOException exc) {
ErrorManager.getDefault().notify(exc);
}
}
}
}
示例4: selectComboBoxItem
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private boolean selectComboBoxItem(String name, boolean setText) {
boolean found = false;
DefaultComboBoxModel model = (DefaultComboBoxModel) comGlobal.getModel();
for (int i = 0; i < model.getSize(); i++) {
GlobalItem gi = (GlobalItem) model.getElementAt(i);
if (gi.getName().equals(name)) {
comGlobal.setSelectedItem(gi);
found = true;
if (setText) {
setTextToGlobalLicense();
}
break;
}
}
if (!found) {
GlobalItem itm = new GlobalItem(name, null);
model.insertElementAt(itm, 0);
comGlobal.setSelectedItem(itm);
if (setText) {
setTextToGlobalLicense();
}
}
return found;
}
示例5: initCombo
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void initCombo(JComboBox providerCombo) {
DefaultComboBoxModel providers = new DefaultComboBoxModel();
for(Provider each : providerSupplier.getSupportedProviders()){
providers.addElement(each);
}
if (providers.getSize() == 0 && providerSupplier.supportsDefaultProvider()){
providers.addElement(ProviderUtil.DEFAULT_PROVIDER);
}
if (providers.getSize() == 0){
providers.addElement(EMPTY);
}
providerCombo.setModel(providers);
providerCombo.addItem(SEPARATOR);
providerCombo.addItem(new NewPersistenceLibraryItem());
providerCombo.addItem(new ManageLibrariesItem());
providerCombo.setRenderer(new PersistenceProviderCellRenderer(getDefaultProvider(providers)));
//select either default or first or preferred provider depending on project details
int selectIndex = 0;
if(providers.getSize()>1 && providers.getElementAt(0) instanceof Provider){
String defProviderVersion = ProviderUtil.getVersion((Provider) providers.getElementAt(0));
boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider
if(specialCase){
for (int i = 1; i<providers.getSize() ; i++){
if(preferredProvider.equals(providers.getElementAt(i))){
selectIndex = i;
break;
}
}
}
}
providerCombo.setSelectedIndex(selectIndex);
}
示例6: ClassNamePanel
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Creates new form ClassNamePanel
*/
public ClassNamePanel(Project project, FileObject anchor, String initialName) {
this.project = project;
this.anchor = anchor;
initComponents();
Project openProjects[] = OpenProjects.getDefault().getOpenProjects();
Arrays.sort( openProjects, new ProjectByDisplayNameComparator());
DefaultComboBoxModel projectsModel = new DefaultComboBoxModel( openProjects );
projectSelector.setModel( projectsModel );
if (project != null) {
projectSelector.setSelectedItem( project );
projectSelector.setEnabled(false);
projectLabel.setEnabled(false);
} else if (projectsModel.getSize() > 0) {
this.project = (Project)projectsModel.getElementAt(0);
projectsModel.setSelectedItem(this.project);
}
projectSelector.setRenderer(new ProjectCellRenderer());
locationSelect.setRenderer(new GroupCellRenderer());
packageSelect.setRenderer(PackageView.listRenderer());
updateRoots();
updatePackages();
selectInitialPackage();
ActionListener al = this::actionPerformed;
locationSelect.addActionListener(al);
packageSelect.addActionListener(al);
packageSelect.getEditor().addActionListener(al);
projectSelector.addActionListener(al);
className.getDocument().addDocumentListener(this);
if (initialName != null) {
className.setText(initialName);
}
}