本文整理汇总了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;
}
示例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: 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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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));
}
示例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);
}
}
}
示例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();
}
示例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;
}