本文整理汇总了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);
}
示例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());
}
}
示例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;
}
示例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();
}
});
}
}
}
示例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();
}
示例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
}
}
示例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>();
}
示例8: removeBuildable
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void removeBuildable(Object type) {
DefaultListModel<BuildableType> model
= (DefaultListModel<BuildableType>)this.buildQueueList.getModel();
model.removeElement(type);
}