当前位置: 首页>>代码示例>>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;未经允许,请勿转载。