當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultListModel.removeElement方法代碼示例

本文整理匯總了Java中javax.swing.DefaultListModel.removeElement方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultListModel.removeElement方法的具體用法?Java DefaultListModel.removeElement怎麽用?Java DefaultListModel.removeElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.DefaultListModel的用法示例。


在下文中一共展示了DefaultListModel.removeElement方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setDisplayedGroups

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:BreakpointNestedGroupsDialog.java

示例2: exportDone

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
/**
 * {@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());
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:20,代碼來源:TradeRouteInputPanel.java

示例3: reorderProjects

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
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;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:22,代碼來源:InjectScript.java

示例4: removeGroups

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
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();
                }
            });
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:ManageGroupsPanel.java

示例5: keyStrokeRemoveActionPerformed

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:GUIRegistrationPanel.java

示例6: updateAllLists

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
/**
 * Update all the lists and buttons, using
 *      {@link #updateBuildingList()} and
 *      {@link #updateUnitList()}
 */
private 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
    }
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:42,代碼來源:BuildQueuePanel.java

示例7: jRemoveAllOfficesButtonAction

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
private void jRemoveAllOfficesButtonAction(java.awt.event.ActionEvent evt) {
    DefaultListModel selectedModel = (DefaultListModel) jOfficeSelected.getModel();

    while (selectedModel.getSize() > 0) {
        QOffice officeToRemove = (QOffice) selectedModel.getElementAt(0);
        selectedModel.removeElement(officeToRemove);
        officesToRemove.add(officeToRemove);
    }

    //Clear the add list, since we're removing all of the offices
    officesToAdd = new LinkedList<QOffice>();
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:13,代碼來源:FServiceChangeDialod.java

示例8: removeBuildable

import javax.swing.DefaultListModel; //導入方法依賴的package包/類
private void removeBuildable(Object type) {
    DefaultListModel<BuildableType> model
        = (DefaultListModel<BuildableType>)this.buildQueueList.getModel();
    model.removeElement(type);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:6,代碼來源:BuildQueuePanel.java


注:本文中的javax.swing.DefaultListModel.removeElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。