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


Java JList.getSelectedIndices方法代碼示例

本文整理匯總了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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:QueryParameter.java

示例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();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:ListTransferHandler.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:TableUISupport.java

示例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));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:FolderList.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:CodeCompletionPanel.java

示例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" });
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:JListJavaElement.java

示例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);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:14,代碼來源:TradeRouteInputPanel.java

示例8: createTransferable

import javax.swing.JList; //導入方法依賴的package包/類
@Override
protected Transferable createTransferable(JComponent c) {
    JList list = (JList) c;
    return new JListTransferable(list.getSelectedIndices());
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:6,代碼來源:InjectScript.java


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