zoukankan      html  css  js  c++  java
  • e783. 监听对JList中项双击和三击

     // Create a list
        String[] items = {"A", "B", "C", "D"};
        JList list = new JList(items);
        
        // Add a listener for mouse clicks
        list.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
                JList list = (JList)evt.getSource();
                if (evt.getClickCount() == 2) {          // Double-click
                    // Get item index
                    int index = list.locationToIndex(evt.getPoint());
                } else if (evt.getClickCount() == 3) {   // Triple-click
                    // Get item index
                    int index = list.locationToIndex(evt.getPoint());
        
                    // Note that this list will receive a double-click event before this triple-click event
                }
            }
        });
    
    Related Examples
  • 相关阅读:
    python
    car-travel project
    数据库
    kafka笔记
    cloudera笔记
    上课笔记
    structured streaming
    SparkSQL
    流数据
    spark厦门大学
  • 原文地址:https://www.cnblogs.com/borter/p/9596136.html
Copyright © 2011-2022 走看看