本文整理汇总了Java中javax.swing.DefaultComboBoxModel.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultComboBoxModel.getSize方法的具体用法?Java DefaultComboBoxModel.getSize怎么用?Java DefaultComboBoxModel.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultComboBoxModel
的用法示例。
在下文中一共展示了DefaultComboBoxModel.getSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: updateTargetsModel
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void updateTargetsModel() {
Object originalSelected = targetsComboBox.getSelectedItem();
DefaultComboBoxModel<TargetDescription> model = new DefaultComboBoxModel<>();
int lastGood = -1;
for (TargetDescription td : targets) {
if (duplicates.isSelected() && !td.allowForDuplicates) continue;
model.addElement(td);
if (!td.anonymous) lastGood++;
}
targetsComboBox.setModel(model);
if (originalSelected != null) targetsComboBox.setSelectedItem(originalSelected);
else if (lastGood >= 0) targetsComboBox.setSelectedIndex(lastGood);
else if (model.getSize() > 0) targetsComboBox.setSelectedIndex(0);
targetsComboBox.setEnabled(model.getSize() != 1);
}
示例3: 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;
}
示例4: update
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
void update () {
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (String mimeType : controller.getMimeTypes()) {
model.addElement(mimeType);
}
languageCombo.setModel(model);
lastSelectedMimeType = controller.getSavedSelectedLanguage();
if (lastSelectedMimeType != null && model.getSize() > 0) {
languageCombo.setSelectedItem(lastSelectedMimeType);
return;
}
JTextComponent pane = EditorRegistry.lastFocusedComponent();
String preSelectMimeType = pane != null ? (String)pane.getDocument().getProperty("mimeType") : ""; // NOI18N
languageCombo.setSelectedItem(preSelectMimeType);
if (!preSelectMimeType.equals (languageCombo.getSelectedItem()) && model.getSize() > 0) {
languageCombo.setSelectedIndex(0);
}
}
示例5: sortComboBoxModel4AgentLists
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Sort ComboBoxModel for agent lists.
*/
private void sortComboBoxModel4AgentLists() {
// --- Move the current entries to a Vector -----------------
Vector<String> agentLists = new Vector<String>();
DefaultComboBoxModel<String> dlm = this.comboBoxModel4AgentLists;
for (int i = 0; i < dlm.getSize(); i++) {
agentLists.add((String) dlm.getElementAt(i));
}
// --- If the default list is not there, create it ----------
if (agentLists.contains(AGENT_LIST_ManualConfiguration)==false) {
this.getAgentDefaultListModel(new DefaultListModel<AgentClassElement4SimStart>(), AGENT_LIST_ManualConfiguration);
agentLists.add(AGENT_LIST_ManualConfiguration);
}
// --- Sort the list ----------------------------------------
Collections.sort(agentLists);
// --- Recreate the JComboBoxModel for agent lists ----------
this.comboBoxModel4AgentLists = new DefaultComboBoxModel<String>();
for (int i = 0; i < agentLists.size(); i++) {
this.comboBoxModel4AgentLists.addElement(agentLists.get(i));
}
}
示例6: 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);
}
示例7: 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);
}
}
示例8: loadComboBox
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void loadComboBox() {
DefaultComboBoxModel model = new DefaultComboBoxModel();
Project[] prjs = OpenProjects.getDefault().getOpenProjects();
Arrays.sort(prjs, Util.projectDisplayNameComparator());
for (int i = 0; i < prjs.length; i++) {
if (prjs[i] != data.getProject()) {
// ignore the currently active project..
model.addElement(prjs[i]);
}
}
if (model.getSize() == 0) {
model.addElement(EMPTY);
}
comProject.setModel(model);
}
示例9: getSuggestedModel
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private ComboBoxModel<String> getSuggestedModel() {
DefaultComboBoxModel<String> m = new DefaultComboBoxModel<>();
for (String s : searchList) {
if (s.toLowerCase().contains(getSearchString().toLowerCase())) {
m.addElement(s);
}
}
if (m.getSize() == 0) {
m = new DefaultComboBoxModel<>(searchList.toArray(new String[searchList.size()]));
}
return m;
}
示例10: addEntry
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Add another entry to the list of errors.
* @param file The file containing the error
* @param check The condition that was being tested, and which failed
* @param encl the enclosing tree node
* @param self the tree node containing the error
*/
void addEntry(JavaFileObject file, String check, Info encl, Info self) {
Entry e = new Entry(file, check, encl, self);
DefaultComboBoxModel m = (DefaultComboBoxModel) entries.getModel();
m.addElement(e);
if (m.getSize() == 1)
entries.setSelectedItem(e);
}
示例11: jButton1ActionPerformed
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Object obj = lstMappings.getSelectedValue();
if (obj != null) {
MappingWrapper wr = (MappingWrapper)obj;
if (wr.getToolbarIconPath() != null) {
wr.setToolbarPath(null);
updateToolbarButton(wr);
} else {
//add
JPanel pnl = new JPanel();
pnl.setLayout(new FlowLayout(FlowLayout.LEADING));
pnl.add(new JLabel(LBL_SetIcon()));
List<String> allIcons = RunCustomMavenAction.createAllActionIcons();
for (int i = 0; i < lstMappings.getModel().getSize(); i++) {
MappingWrapper wr0 = (MappingWrapper) lstMappings.getModel().getElementAt(i);
if (wr0.getToolbarIconPath() != null) {
allIcons.remove(wr0.getToolbarIconPath());
}
}
DefaultComboBoxModel<String> cbModel = new DefaultComboBoxModel<String>(allIcons.toArray(new String[0]));
boolean hasAvailable;
if (cbModel.getSize() != 0) {
hasAvailable = true;
JComboBox<String> cb = new JComboBox<String>();
cb.setModel(cbModel);
pnl.add(cb);
cb.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList arg0, Object arg1, int arg2, boolean arg3, boolean arg4) {
Component sup = super.getListCellRendererComponent(arg0, arg1, arg2, arg3, arg4);
if (sup instanceof JLabel && arg1 != null) {
JLabel lbl = (JLabel) sup;
lbl.setIcon(ImageUtilities.loadImageIcon((String) arg1, false));
lbl.setText("");
}
return sup;
}
});
} else {
hasAvailable = false;
pnl.add(new JLabel(LBL_No_More_Icons()));
}
DialogDescriptor dd = new DialogDescriptor(pnl, TIT_SetIcon());
if (!hasAvailable) {
dd.setOptions(new Object[] {BTN_Close()});
dd.setClosingOptions(dd.getOptions());
}
Object ret = DialogDisplayer.getDefault().notify(dd);
if (ret == DialogDescriptor.OK_OPTION) {
wr.setToolbarPath((String) cbModel.getSelectedItem());
updateToolbarButton(wr);
}
}
}
}
示例12: afterCreate
import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
* Чтоб не дублировать код
*
* @param str список пользователей
*/
private void afterCreate(Object[] users) {
jLabel1.setText(getLocaleMessage("jLabel1.text"));
jLabel2.setText(getLocaleMessage("jLabel2.text"));
buttonEnter.setText(getLocaleMessage("pressOK.Action.text"));
buttonExit.setText(getLocaleMessage("pressCancel.Action.text"));
FAbout.loadVersionSt();
labelName.setText(FAbout.NAME_);
DefaultComboBoxModel m = new DefaultComboBoxModel(users);
comboBoxUser.setModel(m);
final File f = new File("temp/lusr");
if (f.exists()) {
String str = "";
try (FileInputStream fis = new FileInputStream(f); Scanner s = new Scanner(
new InputStreamReader(fis, "UTF-8"))) {
while (s.hasNextLine()) {
final String line = s.nextLine().trim();
str += line;
}
} catch (IOException ex) {
}
if (!"".equals(str) && str.matches("-?\\d+(\\.\\d+)?")) {
for (int i = 0; i < m.getSize(); i++) {
if (((QUser) (m.getElementAt(i))).getId().equals(Long.parseLong(str))) {
m.setSelectedItem(m.getElementAt(i));
break;
}
}
}
}
//привязка помощи к форме.
final Helper helper = Helper.getHelp(
level == LEVEL_ADMIN ? "ru/apertum/qsystem/client/help/admin.hs"
: "ru/apertum/qsystem/client/help/client.hs");
helper.enableHelpKey(qPanel1, "loginning");
addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
labelLavel.setLocation(2, getHeight() - 15);
labelServer.setLocation(5, getHeight() - 45);
}
});
}