本文整理汇总了Java中javax.swing.DefaultListModel.set方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel.set方法的具体用法?Java DefaultListModel.set怎么用?Java DefaultListModel.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultListModel
的用法示例。
在下文中一共展示了DefaultListModel.set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveUpButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void moveUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveUpButtonActionPerformed
int[] indexes = displayedGroupsList.getSelectedIndices();
DefaultListModel displayedModel = (DefaultListModel) displayedGroupsList.getModel();
for (int index : indexes) {
Object down = displayedModel.get(index - 1);
Object up = displayedModel.get(index);
displayedModel.set(index, down);
displayedModel.set(index - 1, up);
}
for (int i = 0; i < indexes.length; i++) {
indexes[i]--;
}
displayedGroupsList.setSelectedIndices(indexes);
}
示例2: moveDownButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void moveDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveDownButtonActionPerformed
int[] indexes = displayedGroupsList.getSelectedIndices();
DefaultListModel displayedModel = (DefaultListModel) displayedGroupsList.getModel();
for (int index : indexes) {
Object down = displayedModel.get(index);
Object up = displayedModel.get(index + 1);
displayedModel.set(index + 1, down);
displayedModel.set(index, up);
}
for (int i = 0; i < indexes.length; i++) {
indexes[i]++;
}
displayedGroupsList.setSelectedIndices(indexes);
}
示例3: setModel
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
* Set the content of the model to the list.
* @param model
* @param list items that will be inserted into the model.
*/
private void setModel(DefaultListModel model, List<T> list) {
model.setSize(list.size() + 1);
model.set(0, getNewItemLabel());
for (int i = 0; i < list.size(); ++i) {
model.set(i + 1, list.get(i));
}
}
示例4: importData
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
@Override public boolean importData(TransferHandler.TransferSupport info) {
if (!info.isDrop()) {
return false;
}
JList list = (JList) info.getComponent();
DefaultListModel listModel = (DefaultListModel) list.getModel();
JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
int index = dl.getIndex();
boolean insert = dl.isInsert();
// Get the string that is being dropped.
Transferable t = info.getTransferable();
String data;
try {
data = (String) t.getTransferData(DataFlavor.stringFlavor);
} catch (Exception e) {
return false;
}
// Perform the actual import.
if (insert) {
listModel.add(index, data);
} else {
listModel.set(index, data);
}
return true;
}