Java Code Examples for javax.swing.DefaultListModel#removeElement()
The following examples show how to use
javax.swing.DefaultListModel#removeElement() .
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: RoarPreferencePanel.java From Spark with Apache License 2.0 | 6 votes |
private void toggleDifferentSettingsForGroup(boolean isSelected) { DefaultListModel<ColorTypes> model = (DefaultListModel<ColorTypes>) _singleColorlist.getModel(); JTextField duration = retrieveComponent("group.duration", JTextField.class); if (isSelected) { if (!model.contains(ColorTypes.BACKGROUNDCOLOR_GROUP)) { model.addElement(ColorTypes.BACKGROUNDCOLOR_GROUP); model.addElement(ColorTypes.HEADERCOLOR_GROUP); model.addElement(ColorTypes.TEXTCOLOR_GROUP); } duration.setEnabled(true); } else { model.removeElement(ColorTypes.BACKGROUNDCOLOR_GROUP); model.removeElement(ColorTypes.HEADERCOLOR_GROUP); model.removeElement(ColorTypes.TEXTCOLOR_GROUP); duration.setEnabled(false); duration.setText(_duration.getText()); } }
Example 2
Source File: RoarPreferencePanel.java From Spark with Apache License 2.0 | 6 votes |
private void toggleDifferentSettingsForKeyword(boolean isSelected) { DefaultListModel<ColorTypes> model = (DefaultListModel<ColorTypes>) _singleColorlist.getModel(); JTextField duration = retrieveComponent("keyword.duration", JTextField.class); if (isSelected) { if (!model.contains(ColorTypes.BACKGROUNDCOLOR_KEYWORD)) { model.addElement(ColorTypes.BACKGROUNDCOLOR_KEYWORD); model.addElement(ColorTypes.HEADERCOLOR_KEYWORD); model.addElement(ColorTypes.TEXTCOLOR_KEYWORD); } duration.setEnabled(true); } else { model.removeElement(ColorTypes.BACKGROUNDCOLOR_KEYWORD); model.removeElement(ColorTypes.HEADERCOLOR_KEYWORD); model.removeElement(ColorTypes.TEXTCOLOR_KEYWORD); duration.setEnabled(false); duration.setText(_duration.getText()); } }
Example 3
Source File: QueryLibraryPanel.java From wandora with GNU General Public License v3.0 | 6 votes |
public void deleteClicked(){ Object o=queryList.getSelectedValue(); if(o==null) return; String openName=o.toString(); if(WandoraOptionPane.showConfirmDialog(Wandora.getWandora(), "Do you want to delete query "+openName) == WandoraOptionPane.YES_OPTION ){ synchronized(storedQueries) { for(StoredQuery q : storedQueries){ if(q.name.equals(openName)){ storedQueries.remove(q); DefaultListModel model=(DefaultListModel)queryList.getModel(); model.removeElement(o); writeQueries(Wandora.getWandora().getOptions()); break; } } } } }
Example 4
Source File: ScrWordClasses.java From PolyGlot with MIT License | 6 votes |
private void deleteWordProperty() { WordClass prop = lstProperties.getSelectedValue(); int position = lstProperties.getSelectedIndex(); if (prop == null || InfoBox.yesNoCancel("Are you sure?", "This will delete the class from all words." + " Values will be irretrievably lost.", core.getRootWindow()) != JOptionPane.YES_OPTION) { return; } try { core.getWordClassCollection().deleteNodeById(prop.getId()); } catch (Exception e) { IOHandler.writeErrorLog(e); InfoBox.error("Unable to Delete", "Unable to delete property: " + e.getLocalizedMessage(), core.getRootWindow()); } DefaultListModel listModel = (DefaultListModel) lstProperties.getModel(); listModel.removeElement(prop); if (position == 0) { lstProperties.setSelectedIndex(position); } else { lstProperties.setSelectedIndex(position - 1); } }
Example 5
Source File: BreakpointNestedGroupsDialog.java From netbeans with Apache License 2.0 | 6 votes |
void setDisplayedGroups(String[] groupNames) { DefaultListModel availableModel = (DefaultListModel) availableGroupsList.getModel(); DefaultListModel model = new DefaultListModel(); for (String groupName : groupNames) { Group g; try { g = Group.valueOf(groupName); } catch (IllegalArgumentException iaex) { continue; } GroupElement ge = new GroupElement(g); model.addElement(ge); availableModel.removeElement(ge); } displayedGroupsList.setModel(model); }
Example 6
Source File: TradeRouteInputPanel.java From freecol with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void exportDone(JComponent source, Transferable data, int action) { try { if (source instanceof JList && action == MOVE) { JList stopList = (JList)source; DefaultListModel listModel = (DefaultListModel)stopList.getModel(); for (Object o : (List) data.getTransferData(STOP_FLAVOR)) { listModel.removeElement(o); } } } catch (Exception e) { logger.warning(e.toString()); } }
Example 7
Source File: InjectScript.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
private Boolean reorderProjects(TransferHandler.TransferSupport support) { JList list = (JList) support.getComponent(); try { int[] selectedIndices = (int[]) support.getTransferable().getTransferData(INDICES); DefaultListModel model = (DefaultListModel) list.getModel(); JList.DropLocation dl = (JList.DropLocation) support.getDropLocation(); if (dl.getIndex() != -1) { for (int selectedIndex : selectedIndices) { Object value = model.get(selectedIndex); model.removeElement(value); model.add(dl.getIndex(), value); } return true; } else { LOG.warning("Invalid Drop Location"); } } catch (UnsupportedFlavorException | IOException ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } return false; }
Example 8
Source File: StringSetPropertyEditorPanel.java From openAGV with Apache License 2.0 | 5 votes |
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed String value = itemsList.getSelectedValue(); if (value == null) { return; } DefaultListModel<String> model = (DefaultListModel<String>) itemsList.getModel(); model.removeElement(value); }
Example 9
Source File: NVCompress.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
private void btnRemoveFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveFilesActionPerformed Object[] selected = lstFileList.getSelectedValues(); DefaultListModel listModel = (DefaultListModel) lstFileList.getModel(); for (Object val : selected){ listModel.removeElement(val); } }
Example 10
Source File: VillageTagFrame.java From dsworkbench with Apache License 2.0 | 5 votes |
private void deleteTags() { Tag tag = null; try { tag = (Tag) jTagsList.getSelectedValue(); } catch (ClassCastException cce) { //no tags availabler JOptionPaneHelper.showWarningBox(this, "Keine Gruppen vorhanden. Bitte importiere zuerst Gruppen aus dem Spiel oder lege sie in der Gruppen-Ansicht manuell an.", "Warnung"); return; } if (tag == null) { return; } if (jPlayerName.getText().equals("Mehrfachauswahl")) { for (int i = 0; i < jVillageList.getItemCount(); i++) { Village v = (Village) jVillageList.getItemAt(i); if (v.getTribe() != Barbarians.getSingleton()) { TagManager.getSingleton().removeTag(v, tag.getName()); } } } else { Village selection = (Village) jVillageList.getSelectedItem(); if (selection == null) { return; } TagManager.getSingleton().removeTag(selection, tag.getName()); } DefaultListModel model = (DefaultListModel) jTagsList.getModel(); model.removeElement(tag); }
Example 11
Source File: BuildQueuePanel.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Update all the lists and buttons, using * {@link #updateBuildingList()} and * {@link #updateUnitList()} */ private final void updateAllLists() { final DefaultListModel<BuildableType> current = (DefaultListModel<BuildableType>)this.buildQueueList.getModel(); this.featureContainer.clear(); for (Enumeration<BuildableType> e = current.elements(); e.hasMoreElements();) { BuildableType type = e.nextElement(); if (getMinimumIndex(type) >= 0) { featureContainer.addFeatures(type); } else { current.removeElement(type); } } // ATTENTION: buildings must be updated first, since units // might depend on the build ability of an unbuildable // building updateBuildingList(); updateUnitList(); // Update the buy button final boolean pay = getSpecification() .getBoolean(GameOptions.PAY_FOR_BUILDING); BuildableType bt = (current.getSize() <= 0) ? null : current.getElementAt(0); this.buyBuildable.setEnabled(bt != null && pay && this.colony.canPayToFinishBuilding(bt)); this.setBuyLabel(bt); // Update the construction panel if (current.getSize() > 0) { this.constructionPanel.update(current.getElementAt(0)); } else if (current.getSize() == 0) { this.constructionPanel.update(); // generates Building: Nothing } }
Example 12
Source File: ManageGroupsPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void removeGroups(Iterable<Group> groups) { DefaultListModel model = (DefaultListModel) groupList.getModel(); for (final Group groupIter : groups) { if(groupIter != null) { model.removeElement(groupIter.getName()); RP.post(new Runnable() { @Override public void run() { groupIter.destroy(); } }); } } }
Example 13
Source File: GUIRegistrationPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void keyStrokeRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyStrokeRemoveActionPerformed DefaultListModel lm = (DefaultListModel)shortcutsList.getModel(); Object[] selected = shortcutsList.getSelectedValues(); if (selected.length > 0) { int idx = shortcutsList.getSelectionModel().getMinSelectionIndex(); for (int i = 0; i < selected.length; i++) { lm.removeElement(selected[i]); } if (lm.getSize() > 0) { idx = (idx > 0) ? idx -1 : 0; shortcutsList.setSelectedIndex(idx); } } checkValidity(); }
Example 14
Source File: FrmJoinNCFiles.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
private void jButton_UnSelecteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_UnSelecteActionPerformed // TODO add your handling code here: DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel(); List<String> selNames = this.jList_SelectedFiles.getSelectedValuesList(); for (String name : selNames){ listModel_sel.removeElement(name); } }
Example 15
Source File: OrderCategoriesPropertyEditorPanel.java From openAGV with Apache License 2.0 | 5 votes |
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed String value = itemsList.getSelectedValue(); if (value == null) { return; } DefaultListModel<String> model = (DefaultListModel<String>) itemsList.getModel(); model.removeElement(value); }
Example 16
Source File: CreateGroupPanel.java From openAGV with Apache License 2.0 | 5 votes |
private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed DefaultListModel<AbstractModelComponent> listModel = (DefaultListModel<AbstractModelComponent>) elementsList.getModel(); List<AbstractModelComponent> selectedObjects = new ArrayList<>(); for (int i : elementsList.getSelectedIndices()) { selectedObjects.add(listModel.get(i)); } for (AbstractModelComponent o : selectedObjects) { listModel.removeElement(o); } revalidate(); }
Example 17
Source File: BuildQueuePanel.java From freecol with GNU General Public License v2.0 | 4 votes |
private void removeBuildable(Object type) { DefaultListModel<BuildableType> model = (DefaultListModel<BuildableType>)this.buildQueueList.getModel(); model.removeElement(type); }