本文整理汇总了Java中javax.swing.DefaultListModel.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel.isEmpty方法的具体用法?Java DefaultListModel.isEmpty怎么用?Java DefaultListModel.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultListModel
的用法示例。
在下文中一共展示了DefaultListModel.isEmpty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addElement
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Adds the element sorted to the model
*
* @param model
* @param element
* @return index of the new element
*/
private int addElement(DefaultListModel<String> model, String element) {
if (model.isEmpty()) {
model.addElement(element);
return 0;
} else {
for (int j = 0; j < model.getSize(); j++) {
int compareValue = String.CASE_INSENSITIVE_ORDER.compare(model.getElementAt(j).toString(), element);
if (compareValue > 0) {
model.add(j, element);
return j;
}
if (j == model.getSize() - 1) {
model.add(j + 1, element);
return j + 1;
}
}
}
// sth went wrong
return -1;
}
示例2: loadRecent
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void loadRecent() {
recentModel = new DefaultListModel();
for (RecentItem recentItem : sMainFrame.getRecentItems().getRECENT_ITEMS()) {
recentModel.addElement(recentItem);
}
recentItems.setModel(recentModel);
if (recentModel.isEmpty()) {
recentToggle.setEnabled(false);
recentToggle.setForeground(Color.GRAY);
appToggle.setSelected(true);
} else {
recentItems.setSelectedIndex(0);
recentToggle.setSelected(true);
}
}
示例3: initTags
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void initTags (String preselectedTag) {
DefaultListModel model = new DefaultListModel();
GitTag selected = null;
GitTag[] tagArray = tags.values().toArray(new GitTag[tags.values().size()]);
Arrays.sort(tagArray, new Comparator<GitTag>() {
@Override
public int compare (GitTag o1, GitTag o2) {
return o1.getTagName().compareTo(o2.getTagName());
}
});
for (GitTag tag : tagArray) {
if (tag.getTagName().equals(preselectedTag)) {
selected = tag;
}
model.addElement(tag);
}
panel.lstTags.setModel(model);
if (selected != null) {
panel.lstTags.setSelectedValue(selected, true);
}
if (quickSearch != null) {
quickSearch.detach();
quickSearch = null;
}
if (!model.isEmpty()) {
quickSearch = GitUtils.attachQuickSearch(Arrays.asList(tagArray), panel.tagsPanel, panel.lstTags, model, new GitUtils.SearchCallback<GitTag>() {
@Override
public boolean contains (GitTag item, String needle) {
return item.getTagName().toLowerCase().contains(needle.toLowerCase());
}
});
}
}
示例4: fill
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public void fill(BufferedReader r) {
DefaultListModel model = new DefaultListModel ();
fillListModel(r, model);
if (!model.isEmpty()) {
list.setModel (model);
}
}
示例5: removeProcessorButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void removeProcessorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeProcessorButtonActionPerformed
DefaultListModel model = (DefaultListModel) annotationProcessorsList.getModel();
int[] indices = annotationProcessorsList.getSelectedIndices();
for (int i = indices.length - 1 ; i >= 0 ; i--) {
model.remove(indices[i]);
}
if (!model.isEmpty()) {
// Select reasonable item
int selectedIndex = indices[indices.length - 1] - indices.length + 1;
if (selectedIndex > model.size() - 1) {
selectedIndex = model.size() - 1;
}
annotationProcessorsList.setSelectedIndex(selectedIndex);
}
}
示例6: applyFilter
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void applyFilter () {
HgBranch selectedBranch = getSelectedBranch();
DefaultListModel targetsModel = new DefaultListModel();
targetsModel.removeAllElements();
HgBranch toSelect = null;
String filter = panel.txtFilter.getText();
synchronized (LOCK) {
for (HgBranch branch : branches) {
if (applies(filter, branch)) {
if (selectedBranch != null && branch.getRevisionInfo().getCSetShortID().equals(selectedBranch.getRevisionInfo().getCSetShortID())) {
toSelect = branch;
} else if (parentRevision != null && branch.getRevisionInfo().getCSetShortID().equals(parentRevision.getChangesetId())) {
toSelect = branch;
}
targetsModel.addElement(branch);
}
}
}
if (targetsModel.isEmpty()) {
targetsModel.addElement(NO_BRANCH);
}
if (!Arrays.equals(targetsModel.toArray(), ((DefaultListModel) panel.branchList.getModel()).toArray())) {
panel.branchList.setModel(targetsModel);
if (toSelect != null) {
panel.branchList.setSelectedValue(toSelect, true);
} else if (targetsModel.size() > 0) {
panel.branchList.setSelectedIndex(0);
}
}
}
示例7: PopuleLista
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void PopuleLista() {
List<Constraint> uni = getSelecionada().getConstraints().stream().filter(c -> c.getTipo() == Constraint.CONSTRAINT_TIPO.tpUNIQUE).collect(Collectors.toList());
DefaultListModel lst = new DefaultListModel();
int t = 1;
for (Constraint contr : uni) {
lst.addElement(Integer.toString(t++) + " - " + contr.getNomeFormatado());
}
Listador.setModel(lst);
if (lst.isEmpty()) {
SetSelConstr(null);
} else {
int idx = (getSelecionada().getConstraintSelecionado() == null) ? 0 : uni.indexOf(getSelecionada().getConstraintSelecionado());
Listador.setSelectedIndex(idx);
}
}
示例8: logFilesList
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private JList<String> logFilesList() {
file = new File(System.getProperty("user.dir") + File.separator + "Logging Store/");
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(file);
fileChooser.setMultiSelectionEnabled(true);
final DefaultListModel<String> model = new DefaultListModel<String>();
final JList<String> list = new JList<String>(model);
list.setPreferredSize(new Dimension(85, 480));
list.setFont(new Font("Dialog", Font.PLAIN, 12));
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setSelectedIndex(0);
list.setFixedCellHeight(18);
list.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getClickCount() == 2) {
selectedItem = list.getSelectedValue();
getSelectedFileName();
}
}
});
list.setCellRenderer(new LogRecordsListRenderer());
File[] selectedFiles = fileChooser.getCurrentDirectory().listFiles();
for (File f : selectedFiles) {
if (f.getName().indexOf(".log") != -1) {
model.addElement(f.getName());
}else {
continue;
}
}
if(model.isEmpty()) {
model.addElement("List is empty!");
}
return list;
}