本文整理汇总了Java中javax.swing.DefaultListModel.removeAllElements方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel.removeAllElements方法的具体用法?Java DefaultListModel.removeAllElements怎么用?Java DefaultListModel.removeAllElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultListModel
的用法示例。
在下文中一共展示了DefaultListModel.removeAllElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyFilter
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void applyFilter () {
HgTag selectedBranch = getSelectedTag();
DefaultListModel targetsModel = new DefaultListModel();
targetsModel.removeAllElements();
HgTag toSelect = null;
String filter = panel.txtFilter.getText();
synchronized (LOCK) {
for (HgTag tag : tags) {
if (applies(filter, tag)) {
if (selectedBranch != null && tag.getRevisionInfo().getCSetShortID().equals(selectedBranch.getRevisionInfo().getCSetShortID())) {
toSelect = tag;
} else if (parentRevision != null && tag.getRevisionInfo().getCSetShortID().equals(parentRevision.getChangesetId())) {
toSelect = tag;
}
targetsModel.addElement(tag);
}
}
}
if (!Arrays.equals(targetsModel.toArray(), ((DefaultListModel) panel.tagList.getModel()).toArray())) {
panel.tagList.setModel(targetsModel);
if (toSelect != null) {
panel.tagList.setSelectedValue(toSelect, true);
} else if (targetsModel.size() > 0) {
panel.tagList.setSelectedIndex(0);
}
}
}
示例2: applyFilter
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void applyFilter () {
HgLogMessage selectedRevision = getSelectedRevision();
DefaultListModel targetsModel = new DefaultListModel();
targetsModel.removeAllElements();
HgLogMessage toSelectRevision = null;
String filter = txtFilter.getText();
synchronized (LOCK) {
for (HgLogMessage message : messages) {
if (applies(filter, message)) {
if (selectedRevision != null && message.getCSetShortID().equals(selectedRevision.getCSetShortID())) {
toSelectRevision = message;
} else if (parentRevision != null && message.getCSetShortID().equals(parentRevision.getCSetShortID())) {
toSelectRevision = message;
}
targetsModel.addElement(message);
}
}
}
if (!Arrays.equals(targetsModel.toArray(), ((DefaultListModel) revisionsComboBox.getModel()).toArray())) {
revisionsComboBox.setModel(targetsModel);
if (toSelectRevision != null) {
revisionsComboBox.setSelectedValue(toSelectRevision, true);
} else if (targetsModel.size() > 0) {
revisionsComboBox.setSelectedIndex(0);
}
}
}
示例3: 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);
}
}
}