本文整理汇总了Java中javax.swing.JList.getSelectedIndex方法的典型用法代码示例。如果您正苦于以下问题:Java JList.getSelectedIndex方法的具体用法?Java JList.getSelectedIndex怎么用?Java JList.getSelectedIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JList
的用法示例。
在下文中一共展示了JList.getSelectedIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listOfListsMouseClicked
import javax.swing.JList; //导入方法依赖的package包/类
private void listOfListsMouseClicked(
java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listOfListsMouseClicked
if (evt.getClickCount() > 2) {
final JList list = ((JList) (evt.getComponent()));
if (list.getSelectedIndex() != -1) {
if (JOptionPane.showConfirmDialog(this,
locMes("del1") + " \"" + ((DefaultListModel) (list.getModel()))
.get(list.getSelectedIndex()) + "\"?", locMes("del2"),
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
((DefaultListModel) (list.getModel())).remove(list.getSelectedIndex());
saveState();
}
} else {
listOfLists.getListSelectionListeners()[0].valueChanged(null);
}
}
示例2: actionPerformed
import javax.swing.JList; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
JList list = (JList) e.getSource();
int index = list.getSelectedIndex();
if (index < 0)
return;
CheckListModel model = (CheckListModel) list.getModel();
model.setChecked(index, !model.isChecked(index));
}
示例3: QuickSearchCallback
import javax.swing.JList; //导入方法依赖的package包/类
public QuickSearchCallback (List<T> items, JList component, DefaultListModel model, SearchCallback<T> callback) {
this.items = new ArrayList<T>(items);
results = new ArrayList<T>(items);
this.component = component;
this.model = model;
this.callback = callback;
this.currentPosition = component.getSelectedIndex();
component.addListSelectionListener(this);
}
示例4: javaCompletionExcluderEditButtonActionPerformed
import javax.swing.JList; //导入方法依赖的package包/类
private void javaCompletionExcluderEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderEditButtonActionPerformed
JList list = getSelectedExcluderList();
int index = list.getSelectedIndex();
if (index == -1)
return;
DefaultListModel model = (DefaultListModel) list.getModel();
javaExcluderEditing = (String) model.getElementAt(index);
openExcluderEditor();
}
示例5: updateLabelEtcFromList
import javax.swing.JList; //导入方法依赖的package包/类
/** Updates label and enables/disables ok button. */
private static void updateLabelEtcFromList (JTextField field, JList list, List dirs, JButton okButton) {
int idx = list.getSelectedIndex ();
if (idx == -1) {
field.setText (" "); // NOI18N
field.getAccessibleContext().setAccessibleName(" ");
okButton.setEnabled (false);
} else {
File dir = (File) dirs.get(idx);
field.setText (NbBundle.getMessage(PackagePanel.class, "LBL_dirWillBe", dir.getAbsolutePath ()));
field.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PackagePanel.class, "LBL_dirWillBe", dir.getAbsolutePath ()));
okButton.setEnabled (true);
}
}
示例6: importString
import javax.swing.JList; //导入方法依赖的package包/类
protected void importString(JComponent c, String str) {
JList target = (JList) c;
DefaultListModel listModel = (DefaultListModel) target.getModel();
int index = target.getSelectedIndex();
// Prevent the user from dropping data back on itself.
// For example, if the user is moving items #4,#5,#6 and #7 and
// attempts to insert the items after item #5, this would
// be problematic when removing the original items.
// So this is not allowed.
if (indices != null && index >= indices[0] - 1 && index <= indices[indices.length - 1]) {
indices = null;
return;
}
int max = listModel.getSize();
if (index < 0) {
index = max;
} else {
index++;
if (index > max) {
index = max;
}
}
addIndex = index;
String[] values = str.split("\n");
addCount = values.length;
for (String value : values) {
listModel.add(index++, value);
}
}
示例7: apptype
import javax.swing.JList; //导入方法依赖的package包/类
private void apptype() {
Engine e = dataPlugin.getEngine();
if (e instanceof Journaled)
((Journaled) e).startUserTransaction();
function.setFont(getJFontChooser().getSelFont());
function.setBackground(getJColorChooser().getColor());
function.setForeground(getJColorChooser1().getColor());
final JList jList = selectOwner.getJList();
if (jList.getSelectedIndex() == 0)
function.setOwner(null);
else {
function.setOwner((Row) jList.getSelectedValue());
}
function.setType(functionType.getType());
AccessRules rules = dataPlugin.getAccessRules();
Element element = ((NFunction) function).getElement();
for (int index = attributes.size() - 1; index >= 0; index--) {
Attribute attribute = attributes.get(index);
if (rules.canUpdateElement(element.getId(), attribute.getId())) {
Object value = attributeEditors.get(index).getValue();
if (!equals(value, values.get(index)))
e.setAttribute(element, attribute, value);
}
}
if (e instanceof Journaled)
((Journaled) e).commitUserTransaction();
}
示例8: listFreeServicesMouseClicked
import javax.swing.JList; //导入方法依赖的package包/类
private void listFreeServicesMouseClicked(
java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listFreeServicesMouseClicked
if (evt.getClickCount() > 1) {
final JList list = ((JList) (evt.getComponent()));
if (list.getSelectedIndex() != -1) {
((DefaultListModel) (list.getModel())).remove(list.getSelectedIndex());
}
}
}
示例9: getListItem
import javax.swing.JList; //导入方法依赖的package包/类
public String getListItem(JList<String> list, String[][] items) {
return items[list.getSelectedIndex()][1];
}
示例10: getIndexAt
import javax.swing.JList; //导入方法依赖的package包/类
public static int getIndexAt(JList list, Point point) {
if (point == null)
return list.getSelectedIndex();
return list.locationToIndex(point);
}