Java Code Examples for javax.swing.DefaultListModel#clear()
The following examples show how to use
javax.swing.DefaultListModel#clear() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrFamilies.java From PolyGlot with MIT License | 6 votes |
/** * updates words list for family */ private void updateWordsProp() { FamTreeNode curNode = (FamTreeNode) treFam.getLastSelectedPathComponent(); DefaultListModel<Object> model = (DefaultListModel<Object>) lstWords.getModel(); model.clear(); if (curNode == null) { return; } ConWord[] words; if (chkInclSubFam.isSelected()) { words = curNode.getNode().getWordsIncludeSubs(); } else { words = curNode.getNode().getWords(); } for (int i = 0; i < words.length; i++) { model.add(i, words[i]); } }
Example 2
Source File: FrmJoinNCFiles.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
private void setDataFolder(File path) { if (!path.isDirectory()) return; this.jLabel_DataFolder.setText(path.getAbsolutePath()); DefaultListModel listModel_all = (DefaultListModel)this.jList_AllFiles.getModel(); DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel(); listModel_all.clear(); listModel_sel.clear(); File[] files = path.listFiles(); Arrays.sort(files); for (File file : files) { if (file.isFile()) { String name = file.getName(); listModel_all.addElement(name); } } }
Example 3
Source File: BBoxDBGui.java From bboxdb with Apache License 2.0 | 6 votes |
/** * Refresh the distributions groups * @param listModel */ private void refreshDistributionGroups(final DefaultListModel<String> listModel) { final List<String> distributionGroups = new ArrayList<>(); try { distributionGroups.addAll(guiModel.getDistributionGroups()); } catch (Exception e) { logger.error("Got an exception while loading distribution groups"); } Collections.sort(distributionGroups); listModel.clear(); for(final String distributionGroupName : distributionGroups) { listModel.addElement(distributionGroupName); } guiModel.setDistributionGroup(null); guiModel.unregisterTreeChangeListener(); if(statusLabel != null) { statusLabel.setText(""); } }
Example 4
Source File: NewPluginPanel.java From netbeans with Apache License 2.0 | 6 votes |
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)); } } } }
Example 5
Source File: AntArtifactChooser.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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()); } }
Example 6
Source File: GoToPopup.java From cakephp3-netbeans with Apache License 2.0 | 6 votes |
private void fireChange() { final DefaultListModel<GoToItem> model = (DefaultListModel<GoToItem>) jList1.getModel(); model.clear(); String filter = getFilter(); for (GoToItem item : items) { FileObject fileObject = item.getFileObject(); if (fileObject == null) { continue; } if (fileObject.getNameExt().toLowerCase().contains(filter.toLowerCase())) { model.addElement(item); } } if (!model.isEmpty()) { jList1.setSelectedIndex(0); } jList1.setSize(jList1.getPreferredSize()); jList1.setVisibleRowCount(model.getSize()); firePropertyChange(PopupUtil.COMPONENT_SIZE_CHANGED, null, null); }
Example 7
Source File: RadVizPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void setPlotColumn(int index, boolean plot) { if (plot) { this.colorColumn = index; } else { this.colorColumn = -1; } // ignore list DefaultListModel<String> ignoreModel = (DefaultListModel<String>) 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(); }
Example 8
Source File: RadVizPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
@Override public void setDataTable(DataTable dataTable) { super.setDataTable(dataTable); this.dataTable = dataTable; // ignore list DefaultListModel<String> ignoreModel = (DefaultListModel<String>) 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(); }
Example 9
Source File: QueryLibraryPanel.java From wandora with GNU General Public License v3.0 | 5 votes |
public void readQueries(Options options){ StoredQuery[] queries=null; String queriesJson=options.get(OPTIONS_KEY); if(queriesJson!=null){ JsonMapper mapper=new JsonMapper(); try{ StoredQueries wrapper=(StoredQueries)mapper.readValue(queriesJson,StoredQueries.class); queries=wrapper.queries; } catch(IOException ioe){Wandora.getWandora().handleError(ioe);} } else queries=new StoredQuery[0]; if(queries!=null){ synchronized(storedQueries){ storedQueries.clear(); storedQueries.addAll(Arrays.asList(queries)); DefaultListModel model=(DefaultListModel)queryList.getModel(); model.clear(); for(StoredQuery q : storedQueries){ model.addElement(q); } } } }
Example 10
Source File: SwingConfiguration.java From deobfuscator-gui with Apache License 2.0 | 5 votes |
/** * Clears the component value. */ public void clearValue() { if(type == ItemType.FILE) ((JTextField)component).setText(""); else if(type == ItemType.BOOLEAN) ((JCheckBox)component).setSelected(false); else { DefaultListModel<Object> listModel = (DefaultListModel<Object>)component; listModel.clear(); } }
Example 11
Source File: Environment.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
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); }); }
Example 12
Source File: FrmJoinNCFiles.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
private void jButton_SelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SelectAllActionPerformed // TODO add your handling code here: DefaultListModel listModel_all = (DefaultListModel)this.jList_AllFiles.getModel(); DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel(); listModel_sel.clear(); for (int i = 0; i < listModel_all.getSize(); i++){ listModel_sel.addElement(listModel_all.getElementAt(i)); } }
Example 13
Source File: JSModulesEditor.java From ramus with GNU General Public License v3.0 | 5 votes |
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)); }
Example 14
Source File: EarProjectPropertiesTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testResolveProjectDependencies() throws Exception { int countBefore = EarProjectProperties.getJarContentAdditional(earProject).size(); DefaultListModel l = earProjectProperties.EAR_CONTENT_ADDITIONAL_MODEL.getDefaultListModel(); l.remove(l.indexOf(getEjbProject())); earProjectProperties.store(); EditableProperties ep = TestUtil.loadProjectProperties(earProject.getProjectDirectory()); String ejbReferenceValue = ep.getProperty(EJB_REFERENCE_EXPECTED_KEY); assertNull("ejb reference should not exist", ejbReferenceValue); String carReferenceValue = ep.getProperty(CAR_REFERENCE_EXPECTED_KEY); assertEquals("car reference should exist", CAR_REFERENCE_EXPECTED_VALUE, carReferenceValue); assertEquals("wrong count of project references", countBefore - 1, EarProjectProperties.getJarContentAdditional(earProject).size()); assertEquals("wrong count of project references", countBefore - 1, earProject.getReferenceHelper().getRawReferences().length); // remove all entries l.clear(); earProjectProperties.store(); assertEquals("wrong count of project references", 0, EarProjectProperties.getJarContentAdditional(earProject).size()); // add new project/module l.addElement(getWebProject()); earProjectProperties.store(); ep = TestUtil.loadProjectProperties(earProject.getProjectDirectory()); ejbReferenceValue = ep.getProperty(EJB_REFERENCE_EXPECTED_KEY); assertNull("ejb reference should not exist", ejbReferenceValue); carReferenceValue = ep.getProperty(CAR_REFERENCE_EXPECTED_KEY); assertNull("car reference should not exist", carReferenceValue); String webReferenceValue = ep.getProperty(WEB_REFERENCE_EXPECTED_KEY); assertEquals("web reference should exist", WEB_REFERENCE_EXPECTED_VALUE, webReferenceValue); assertEquals("wrong count of project references", 1, EarProjectProperties.getJarContentAdditional(earProject).size()); assertEquals("wrong count of project references", 1, earProject.getReferenceHelper().getRawReferences().length); }
Example 15
Source File: FolderList.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 16
Source File: CategoryPanelFormatters.java From netbeans with Apache License 2.0 | 5 votes |
@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); } } }
Example 17
Source File: CompareResultImages.java From diirt with MIT License | 5 votes |
private void fillList() { DefaultListModel newModel = (DefaultListModel) toReviewList.getModel(); newModel.clear(); for (TestResultManager.Result result : manager.getCurrentResults()) { newModel.addElement(result); } // toReviewList.setModel(newModel); }
Example 18
Source File: BuildQueuePanel.java From freecol with GNU General Public License v2.0 | 4 votes |
/** * 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<>(8); // 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); } }
Example 19
Source File: BuildQueuePanel.java From freecol with GNU General Public License v2.0 | 4 votes |
/** * 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<>(8); // 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); } }
Example 20
Source File: FrmJoinNCFiles.java From MeteoInfo with GNU Lesser General Public License v3.0 | 4 votes |
private void jButton_UnSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_UnSelectAllActionPerformed // TODO add your handling code here: DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel(); listModel_sel.clear(); }