本文整理汇总了Java中javax.swing.JList.getSelectedIndices方法的典型用法代码示例。如果您正苦于以下问题:Java JList.getSelectedIndices方法的具体用法?Java JList.getSelectedIndices怎么用?Java JList.getSelectedIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JList
的用法示例。
在下文中一共展示了JList.getSelectedIndices方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ListParameter
import javax.swing.JList; //导入方法依赖的package包/类
public ListParameter(JList list, String parameter, String encoding) {
super(parameter, encoding);
this.list = list;
list.setModel(new DefaultListModel());
list.addListSelectionListener(new ListSelectionListener(){
@Override
public void valueChanged(ListSelectionEvent e) {
int[] s = ListParameter.this.list.getSelectedIndices();
if(e.getValueIsAdjusting()) {
return;
}
fireStateChanged();
};
});
original = list.getSelectedIndices();
fireStateChanged();
}
示例2: exportString
import javax.swing.JList; //导入方法依赖的package包/类
protected String exportString(JComponent c) {
JList list = (JList) c;
indices = list.getSelectedIndices();
@SuppressWarnings("deprecation")
Object[] values = list.getSelectedValues();
StringBuffer buff = new StringBuffer();
for (int i = 0; i < values.length; i++) {
Object val = values[i];
buff.append(val == null ? "" : val.toString());
if (i != values.length - 1) {
buff.append("\n");
}
}
return buff.toString();
}
示例3: getSelectedTables
import javax.swing.JList; //导入方法依赖的package包/类
public static Set<Table> getSelectedTables(JList list, boolean enabledOnly) {
Set<Table> result = new HashSet<Table>();
int[] selected = list.getSelectedIndices();
for (int i = 0; i < selected.length; i++) {
Table table = (Table)list.getModel().getElementAt(selected[i]);
if(enabledOnly){
if(!list.getCellRenderer().getListCellRendererComponent(list, table, selected[i], false, false).isEnabled())continue;
}
result.add(table);
}
return result;
}
示例4: createTransferable
import javax.swing.JList; //导入方法依赖的package包/类
@Override
public Transferable createTransferable(JComponent comp) {
final JList list = (JList)comp;
indices = list.getSelectedIndices();
if (indices.length == 0) {
return null;
}
return new FileListTransferable(safeCopy(list.getSelectedValues(),File.class));
}
示例5: javaCompletionExcluderRemoveButtonActionPerformed
import javax.swing.JList; //导入方法依赖的package包/类
private void javaCompletionExcluderRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderRemoveButtonActionPerformed
JList list = getSelectedExcluderList();
int[] rows = list.getSelectedIndices();
DefaultListModel model = (DefaultListModel) list.getModel();
// remove rows in descending order: row numbers change when a row is removed
for (int row = rows.length - 1; row >= 0; row--) {
model.remove(rows[row]);
}
updateExcluder(list);
}
示例6: getSelectionText
import javax.swing.JList; //导入方法依赖的package包/类
public static String getSelectionText(JList list) {
List<Properties> pa = new ArrayList<Properties>();
int[] selectedIndices = list.getSelectedIndices();
for (int index : selectedIndices) {
Properties p = new Properties();
p.setProperty("listText", JListItemJavaElement.getText(list, index));
pa.add(p);
}
return PropertyHelper.toString(pa.toArray(new Properties[pa.size()]), new String[] { "listText" });
}
示例7: createTransferable
import javax.swing.JList; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Transferable createTransferable(JComponent c) {
JList list = (JList)c;
DefaultListModel model = (DefaultListModel)list.getModel();
List<TradeRouteStop> stops = new ArrayList<>();
for (int index : list.getSelectedIndices()) {
stops.add((TradeRouteStop)model.get(index));
}
return new StopListTransferable(stops);
}
示例8: createTransferable
import javax.swing.JList; //导入方法依赖的package包/类
@Override
protected Transferable createTransferable(JComponent c) {
JList list = (JList) c;
return new JListTransferable(list.getSelectedIndices());
}