本文整理汇总了Java中javax.swing.DefaultListModel.clear方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel.clear方法的具体用法?Java DefaultListModel.clear怎么用?Java DefaultListModel.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultListModel
的用法示例。
在下文中一共展示了DefaultListModel.clear方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateGoals
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void updateGoals() {
DefaultListModel m = (DefaultListModel) goalsList.getModel();
m.clear();
if (selVi != null) {
Set<String> goals = null;
try {
goals = PluginIndexManager.getPluginGoals(selVi.getGroupId(),
selVi.getArtifactId(), selVi.getVersion());
} catch (Exception ex) {
// TODO - put err msg in dialog?
Exceptions.printStackTrace(ex);
}
if (goals != null) {
for (String goal : goals) {
m.addElement(new GoalEntry(goal));
}
}
}
}
示例2: populateAccessory
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Set up GUI fields according to the requested project.
* @param project a subproject, or null
*/
private void populateAccessory( Project project ) {
DefaultListModel model = (DefaultListModel)jListArtifacts.getModel();
model.clear();
jTextFieldName.setText(project == null ? "" : ProjectUtils.getInformation(project).getDisplayName()); //NOI18N
if ( project != null ) {
List<AntArtifact> artifacts = new ArrayList<AntArtifact>();
for (int i=0; i<artifactTypes.length; i++) {
artifacts.addAll (Arrays.asList(AntArtifactQuery.findArtifactsByType(project, artifactTypes[i])));
}
for(AntArtifact artifact : artifacts) {
URI uris[] = artifact.getArtifactLocations();
for( int y = 0; y < uris.length; y++ ) {
model.addElement( new AntArtifactItem(artifact, uris[y]));
}
}
jListArtifacts.setSelectionInterval(0, model.size());
}
}
示例3: setDataTable
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
@Override
public void setDataTable(DataTable dataTable) {
super.setDataTable(dataTable);
this.dataTable = dataTable;
// ignore list
DefaultListModel ignoreModel = (DefaultListModel) ignoreList.getModel();
ignoreModel.clear();
for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
if (i == colorColumn) {
continue;
}
ignoreModel.addElement(this.dataTable.getColumnName(i));
}
this.maxWeight = getMaxWeight(dataTable);
repaint();
}
示例4: setPlotColumn
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
@Override
public void setPlotColumn(int index, boolean plot) {
if (plot) {
this.colorColumn = index;
} else {
this.colorColumn = -1;
}
// ignore list
DefaultListModel ignoreModel = (DefaultListModel) ignoreList.getModel();
ignoreModel.clear();
for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
if (i == this.colorColumn) {
continue;
}
ignoreModel.addElement(this.dataTable.getColumnName(i));
}
repaint();
}
示例5: initHistoryItem
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void initHistoryItem() {
DefaultListModel lm = (DefaultListModel) historyList.getModel();
lm.clear();
try {
FileUtil.getConfig("");//初始化数据
String hisFilter = historyFilter.getText();
for (Map.Entry<String, HttpConfig> entry : FileUtil.CONFIG_MAP.entrySet()) {
String key1 = entry.getKey();
if (hisFilter != null && !hisFilter.isEmpty()) {
HttpConfig hc = entry.getValue();
if (!key1.toLowerCase().contains(hisFilter.toLowerCase()) && !hc.getUrl().toLowerCase().contains(hisFilter.toLowerCase())) {
continue;
}
}
if (key1.contains("登录")) {
lm.insertElementAt(key1, 0);
} else {
lm.addElement(key1);
}
}
} catch (Exception ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例6: load
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
@Override
public void load() {
VariablesFormatter[] formatters = VariablesFormatter.loadFormatters();
DefaultListModel filterClassesModel = (DefaultListModel) formattersList.getModel();
filterClassesModel.clear();
if (formatters != null) {
for (int i = 0; i < formatters.length; i++) {
filterClassesModel.addElement(formatters[i]);
}
if (formatters.length > 0) {
formattersList.setSelectedValue(formatters[0], true);
}
}
}
示例7: setFiles
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public void setFiles (File[] files) {
DefaultListModel model = ((DefaultListModel)this.roots.getModel());
model.clear();
for (int i=0; i<files.length; i++) {
model.addElement (files[i]);
}
if (files.length>0) {
this.roots.setSelectedIndex(0);
}
}
示例8: init
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* initialize the other components of the frame
*/
public void init() {
userNameLabel.setText("Welcome: " + client.getName());
courseList.setModel(new DefaultListModel());
client.sendUTFDataToServer("GET_COURSES");
courseArrList = (ArrayList)client.getObjectFromServer();
model = (DefaultListModel) courseList.getModel();
model.clear();
for(String s : courseArrList) {
model.addElement(s);
}
if(courseArrList.size() == 0) {
model.addElement("No Course");
}
courseList.setModel(model);
courseList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
JList list = (JList) evt.getSource();
int index = list.getSelectedIndex();
if(index != -1) {
constructCoursePanel(index);
constuctAssignmentPanel(index);
}
}
});
downSubBtn.setEnabled(false);
gradeField.setEditable(false);
sendGradeBtn.setEnabled(false);
}
示例9: loadModules
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public void loadModules() {
String[] streamNames = engine.getStreamNames();
DefaultListModel model = (DefaultListModel) jList.getModel();
model.clear();
Arrays.sort(streamNames);
for (String streamName : streamNames)
if (streamName.startsWith(PREFIX))
model.addElement(new Script(streamName));
}
示例10: setContents
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void setContents(List<String> contents) {
DefaultListModel model = (DefaultListModel)getModel();
model.clear();
for (String str : contents) {
model.addElement(new LabelValuePair(str));
}
setVisibleRowCount(Math.min(model.getSize(), 8));
}
示例11: repopulate
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Re-populate the model.
*/
public void repopulate() {
DefaultListModel<AbstractInsnNode> model = (DefaultListModel<AbstractInsnNode>) getModel();
model.clear();
for (AbstractInsnNode ain : method.instructions.toArray()) {
model.addElement(ain);
}
setModel(model);
}
示例12: loadTestDataLists
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void loadTestDataLists() {
DefaultListModel dfM = (DefaultListModel) testDataList.getModel();
dfM.clear();
List<String> values = tdProxy.getListOfTestDatas(environments.getSelectedItem().toString());
values.stream().forEach((value) -> {
dfM.addElement(value);
});
}
示例13: updateBuildingList
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Update the list of available buildings to build
*
* This method will verify whether a building can be built by
* checking against the following criteria:
* * Does the Colony meet the population limit to build?
* * Does the new building require a special circumstance,
* such as a prerequisite unit or building?
*/
private void updateBuildingList() {
final Specification spec = getSpecification();
final DefaultListModel<BuildableType> current
= (DefaultListModel<BuildableType>)this.buildQueueList.getModel();
final DefaultListModel<BuildingType> buildings
= (DefaultListModel<BuildingType>)this.buildingList.getModel();
buildings.clear();
Set<BuildableType> unbuildableTypes = new HashSet<>();
// For each building type, find out if it is buildable, and
// reasons to not build it (and perhaps display a lock icon).
for (BuildingType bt : spec.getBuildingTypeList()) {
if (unbuildableTypes.contains(bt)) continue;
// Impossible upgrade path
if (bt.getUpgradesFrom() != null
&& unbuildableTypes.contains(bt.getUpgradesFrom())) {
unbuildableTypes.add(bt);
continue;
}
// Ignore pre-built buildings
if (!bt.needsGoodsToBuild()) continue;
// Only one building of any kind
if (current.contains(bt) || hasBuildingType(bt)) continue;
List<String> reasons = new ArrayList<>();
// Coastal limit
if (bt.hasAbility(Ability.COASTAL_ONLY)
&& !this.colony.getTile().isCoastland()) {
reasons.add(Messages.message(StringTemplate
.template("buildQueuePanel.coastalOnly")));
}
// Population limit
if (bt.getRequiredPopulation() > this.colony.getUnitCount()) {
reasons.add(Messages.message(StringTemplate
.template("buildQueuePanel.populationTooSmall")
.addAmount("%number%", bt.getRequiredPopulation())));
}
// Spec limits
for (Limit limit : transform(bt.getLimits(),
l -> !l.evaluate(this.colony))) {
reasons.add(Messages.getDescription(limit));
}
// Missing ability
if (!checkAbilities(bt, reasons)) unbuildableTypes.add(bt);
// Upgrade path is blocked
Building colonyBuilding = this.colony.getBuilding(bt);
BuildingType up = bt.getUpgradesFrom();
if (up != null && !current.contains(up)
&& (colonyBuilding == null || colonyBuilding.getType() != up)) {
reasons.add(Messages.getName(up));
}
lockReasons.put(bt, (reasons.isEmpty()) ? null
: Messages.message(StringTemplate
.template("buildQueuePanel.requires")
.addName("%string%", join("/", reasons))));
if (reasons.isEmpty()
|| showAllBox.isSelected()) buildings.addElement(bt);
}
}
示例14: updateUnitList
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Update the list of available units (ships, wagon, artillery) to build
*
* This method will verify whether a unit can be built by
* checking against the following criteria:
* * Does the Colony meet the population limit to build?
* * Does the new building require a special circumstance,
* such as a prerequisite unit or building?
*/
private void updateUnitList() {
final Specification spec = getSpecification();
final Turn turn = getGame().getTurn();
DefaultListModel<UnitType> units
= (DefaultListModel<UnitType>)this.unitList.getModel();
units.clear();
Set<BuildableType> unbuildableTypes = new HashSet<>();
// For each unit type, find out if it is buildable, and
// reasons to not build it (and perhaps display a lock icon).
for (UnitType ut : spec.getBuildableUnitTypes()) {
if (unbuildableTypes.contains(ut)) continue;
List<String> reasons = new ArrayList<>();
// Population limit
if (ut.getRequiredPopulation() > this.colony.getUnitCount()) {
reasons.add(Messages.message(StringTemplate
.template("buildQueuePanel.populationTooSmall")
.addAmount("%number%", ut.getRequiredPopulation())));
}
// Spec limits
for (Limit limit : transform(ut.getLimits(),
l -> !l.evaluate(this.colony))) {
reasons.add(Messages.getDescription(limit));
}
// Missing ability
if (!checkAbilities(ut, reasons)) unbuildableTypes.add(ut);
// Missing unit build ability?
if (!this.featureContainer.hasAbility(Ability.BUILD, ut, null)
&& !this.colony.hasAbility(Ability.BUILD, ut, turn)) {
Ability buildAbility = find(spec.getAbilities(Ability.BUILD),
a -> (a.appliesTo(ut)
&& a.getValue()
&& a.getSource() != null
&& !unbuildableTypes.contains(a.getSource())));
reasons.add((buildAbility != null)
? ((buildAbility.getSource() instanceof Named)
? Messages.getName((Named)buildAbility.getSource())
: Messages.getName(buildAbility))
: Messages.getName(ut));
}
lockReasons.put(ut, (reasons.isEmpty()) ? null
: Messages.message(StringTemplate
.template("buildQueuePanel.requires")
.addName("%string%", join("/", reasons))));
if (reasons.isEmpty()
|| showAllBox.isSelected()) units.addElement(ut);
}
}