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


Java JList.getSelectedIndex方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:20,代码来源:PComplexService.java

示例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));
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CheckList.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:GitUtils.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CodeCompletionPanel.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:PackagePanel.java

示例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);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:32,代码来源:ListTransferHandler.java

示例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();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:35,代码来源:FunctionOptionsDialog.java

示例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());
        }
    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:10,代码来源:PComplexService.java

示例9: getListItem

import javax.swing.JList; //导入方法依赖的package包/类
public String getListItem(JList<String> list, String[][] items) {
	return items[list.getSelectedIndex()][1];
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:4,代码来源:OpenGraphDialog.java

示例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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:6,代码来源:JListJavaElement.java


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