当前位置: 首页>>代码示例>>Java>>正文


Java JList.getSelectedValues方法代码示例

本文整理汇总了Java中javax.swing.JList.getSelectedValues方法的典型用法代码示例。如果您正苦于以下问题:Java JList.getSelectedValues方法的具体用法?Java JList.getSelectedValues怎么用?Java JList.getSelectedValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JList的用法示例。


在下文中一共展示了JList.getSelectedValues方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTransferable

import javax.swing.JList; //导入方法依赖的package包/类
@Override
protected Transferable createTransferable(JComponent c) {
    if (c instanceof JList) {
        JList list = (JList) c;
        Object[] values = list.getSelectedValues();
        if (values == null || values.length == 0) {
            return null;
        }
        List<TaskNode> nodes = new ArrayList<TaskNode>(values.length);
        for (int i = 0; i < values.length; i++) {
            Object val = values[i];
            if (val instanceof TaskNode) {
                nodes.add((TaskNode) val);
            } else {
                return null;
            }
        }
        return new DashboardTransferable(nodes.toArray(new TaskNode[nodes.size()]));
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:DashboardTransferHandler.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: valueChanged

import javax.swing.JList; //导入方法依赖的package包/类
/**
		 * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
		 */
		public void valueChanged(ListSelectionEvent e)
		{
			JList jl = (JList) e.getSource();
			if (jl.getSelectionModel().getValueIsAdjusting())
				return;
            KPartiteGraph bpg2 = (KPartiteGraph)kpg.copy();
//			BipartiteGraph bpg2 = (BipartiteGraph) kpg.copy();
			Object[] selected = jl.getSelectedValues();
//			System.out.println("Value Changed " + Arrays.asList(selected));
			for (int i = 0; i < selected.length; i++)
			{
				Vertex v2 = dates.getVertex((String) selected[i]);
				if (v2 == null)
				{
					System.out.println(
						"No original vertex with label " + selected[i]);
				}
				bpg2.removeVertex((Vertex) v2.getEqualVertex(bpg2));
			}
			wellKnownRenderer.setHiddenList(Arrays.asList(selected));
			foldAndDisplay(bpg2);
		}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:26,代码来源:TestSouthernWomenBipartite.java

示例4: createTransferable

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * Creates the transferable
 *
 * @param c
 * @return Transferable
 */
@Override
protected Transferable createTransferable(JComponent c) {
    JList list = (JList) c;
    Object[] values = list.getSelectedValues();
    String buff = "";
    for (int i = 0; i < values.length; i++) {
        Class val = (Class) values[i];
        buff = val.getName();
    }
    return new StringSelection(buff);
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:18,代码来源:ProcessTransferHandler.java

示例5: getSelectedTables

import javax.swing.JList; //导入方法依赖的package包/类
public static Set<Table> getSelectedTables(JList list) {
    Set<Table> result = new HashSet<Table>();

    Object[] selectedValues = list.getSelectedValues();
    for (int i = 0; i < selectedValues.length; i++) {
        result.add((Table)selectedValues[i]);
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TableUISupport.java

示例6: storeFieldValue

import javax.swing.JList; //导入方法依赖的package包/类
private void storeFieldValue(IssueField field, JList list) {
    List<String> values = new ArrayList<>();
    for (Object value : list.getSelectedValues()) {
        values.add(value.toString());
    }
    if (!issue.getFieldValues(field).equals(values)) {
        addUnsavedField(field.getKey());
        issue.setFieldValues(field, values);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:IssuePanel.java

示例7: createTransferable

import javax.swing.JList; //导入方法依赖的package包/类
@Override
protected Transferable createTransferable(JComponent c) {
	JList source = (JList) c;
	Object[] selectedValues = source.getSelectedValues();
	List<DataTableColumn> columns = new LinkedList<DataTableColumn>();
	if (selectedValues != null) {
		int length = selectedValues.length;
		for (int i = 0; i < length; ++i) {
			columns.add((DataTableColumn) selectedValues[i]);
		}
	}
	return new DataTableColumnCollectionTransferable(new DataTableColumnCollection(columns));
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:DataTableColumnListTransferHandler.java

示例8: focusLost

import javax.swing.JList; //导入方法依赖的package包/类
@Override public void focusLost(RComponent next) {
    JList list = (JList) component;
    Object[] selectedValues = list.getSelectedValues();
    if (next == null || getComponent() != next.getComponent()) {
        if (selectedValues == null || selectedValues.length == 0) {
            recorder.recordSelect(this, "[]");
        } else if (selectedValues.length > 1) {
            String currentListSelectionText = JListJavaElement.getSelectionText((JList) component);
            recorder.recordSelect(this, currentListSelectionText);
        }
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:RList.java

示例9: addToken

import javax.swing.JList; //导入方法依赖的package包/类
@Messages({
    "LBL_ProvidedTokens_T=Provided &Tokens:",
    "ACS_ProvidedTokensTitle=Required tokens panel",
    "ACS_LBL_ProvidedTokens=Required tokens",
    "ACS_CTL_ProvidedTokensVerticalScroll=Required tokens vertical scroll bar",
    "ACSD_CTL_ProvidedTokensVerticalScroll=Required tokens vertical scroll bar",
    "ACS_CTL_ProvidedTokensHorizontalScroll=Required tokens horizontal scroll bar",
    "ACSD_CTL_ProvidedTokensHorizontalScroll=Required tokens horizontal scroll bar",
    "LBL_ProvidedTokens_NoMnem=Provided Tokens:"
})
private void addToken(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addToken
    // create add panel
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    panel.setLayout(new BorderLayout(0, 2));
    JList tokenList = new JList(getProperties().getAllTokens());
    JScrollPane tokenListSP = new JScrollPane(tokenList);
    JLabel provTokensTxt = new JLabel();
    provTokensTxt.setLabelFor(tokenList);
    Mnemonics.setLocalizedText(provTokensTxt, LBL_ProvidedTokens_T());
    panel.getAccessibleContext().setAccessibleDescription(ACS_ProvidedTokensTitle());
    tokenList.getAccessibleContext().setAccessibleDescription(ACS_LBL_ProvidedTokens());
    tokenListSP.getVerticalScrollBar().getAccessibleContext().setAccessibleName(ACS_CTL_ProvidedTokensVerticalScroll());
    tokenListSP.getVerticalScrollBar().getAccessibleContext().setAccessibleDescription(ACSD_CTL_ProvidedTokensVerticalScroll());
    tokenListSP.getHorizontalScrollBar().getAccessibleContext().setAccessibleName(ACS_CTL_ProvidedTokensHorizontalScroll());
    tokenListSP.getHorizontalScrollBar().getAccessibleContext().setAccessibleDescription(ACSD_CTL_ProvidedTokensHorizontalScroll());
    
    panel.add(provTokensTxt, BorderLayout.NORTH);
    panel.add(tokenListSP, BorderLayout.CENTER);
    
    DialogDescriptor descriptor = new DialogDescriptor(panel,
            LBL_ProvidedTokens_NoMnem());
    Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    d.setVisible(true);
    d.dispose();
    if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
        Object[] selected = tokenList.getSelectedValues();
        CustomizerComponentFactory.RequiredTokenListModel model = (CustomizerComponentFactory.RequiredTokenListModel) reqTokenList.getModel();
        for (int i = 0; i < selected.length; i++) {
            model.addToken((String) selected[i]);
        }
        if (selected.length > 0) {
            reqTokenList.clearSelection();
            reqTokenList.setSelectedValue(selected[0], true);
        }
    }
    reqTokenList.requestFocusInWindow();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:CustomizerLibraries.java

示例10: selectProcessToKill

import javax.swing.JList; //导入方法依赖的package包/类
static List<BuildExecutionSupport.Item> selectProcessToKill(List<BuildExecutionSupport.Item> toStop) {
    // Add all threads, sorted by display name.
    DefaultListModel model = new DefaultListModel();
    StopBuildingAlert alert = new StopBuildingAlert();
    final JList list = alert.buildsList;
    Comparator<BuildExecutionSupport.Item> comp = new Comparator<BuildExecutionSupport.Item>() {
        private final Collator coll = Collator.getInstance();
        @Override
        public int compare(BuildExecutionSupport.Item t1, BuildExecutionSupport.Item t2) {
            String n1 = t1.getDisplayName();
            String n2 = t2.getDisplayName();
            int r = coll.compare(n1, n2);
            if (r != 0) {
                return r;
            } else {
                // Arbitrary. XXX Note that there is no way to predict which is
                // which if you have more than one build running. Ideally it
                // would be subsorted by creation time, probably.
                return System.identityHashCode(t1) - System.identityHashCode(t2);
            }
        }
    };
    SortedSet<BuildExecutionSupport.Item> items = new TreeSet<BuildExecutionSupport.Item>(comp);
    items.addAll(toStop);

    for (BuildExecutionSupport.Item t : items) {
        model.addElement(t);
    }
    list.setModel(model);
    list.setSelectedIndex(0);
    // Make a dialog with buttons "Stop Building" and "Cancel".
    DialogDescriptor dd = new DialogDescriptor(alert, NbBundle.getMessage(StopBuildingAlert.class, "TITLE_SBA"));
    dd.setMessageType(NotifyDescriptor.PLAIN_MESSAGE);
    final JButton stopButton = new JButton(NbBundle.getMessage(StopBuildingAlert.class, "LBL_SBA_stop"));
    list.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            stopButton.setEnabled(list.getSelectedValue() != null);
        }
    });
    dd.setOptions(new Object[] {stopButton, DialogDescriptor.CANCEL_OPTION});
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
    List<BuildExecutionSupport.Item> toRet = new ArrayList<BuildExecutionSupport.Item>();
    if (dd.getValue() == stopButton) {
        Object[] selectedItems = list.getSelectedValues();
        for (Object o : selectedItems) {
            toRet.add((BuildExecutionSupport.Item)o);
        }
    }
    return toRet;

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:StopBuildingAlert.java


注:本文中的javax.swing.JList.getSelectedValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。