javax.swing.JList.locationToIndex()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中javax.swing.JList.locationToIndex()方法的一些代码示例,展示了JList.locationToIndex()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JList.locationToIndex()方法的具体详情如下:
包路径:javax.swing.JList
类名称:JList
方法名:locationToIndex

JList.locationToIndex介绍

暂无

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
public void mouseClicked(MouseEvent e) {
  if( SwingUtilities.isRightMouseButton(e) ){
    @SuppressWarnings("unchecked")
    JList<PathPrinter> list = (JList<PathPrinter>)e.getSource();
    int row = list.locationToIndex(e.getPoint());
    list.setSelectedIndex(row);
    
    popup.show(list, e.getX(), e.getY());
  }
}

代码示例来源:origin: deathmarine/Luyten

JList<String> list = (JList<String>) evt.getSource();
if (evt.getClickCount() == 2) {
  int index = list.locationToIndex(evt.getPoint());
  String entryName = (String) list.getModel().getElementAt(index);
  String[] array = entryName.split("/");

代码示例来源:origin: stackoverflow.com

list.addMouseListener( new MouseAdapter()
{
  public void mousePressed(MouseEvent e)
  {
    if ( SwingUtilities.isRightMouseButton(e) )
    {
      JList list = (JList)e.getSource();
      int row = list.locationToIndex(e.getPoint());
      list.setSelectedIndex(row);
    }
  }

});

代码示例来源:origin: stackoverflow.com

public void mouseClicked(MouseEvent e) {
  JList list = (JList) e.getSource();
  if (list.locationToIndex(e.getPoint()) == -1 && !e.isShiftDown()
      && !isMenuShortcutKeyDown(e)) {
    list.clearSelection();

代码示例来源:origin: chatty/chatty

/**
 * Select the list item at the location of this MouseEvent, if any.
 * 
 * @param e The MouseEvent
 */
private void selectClicked(MouseEvent e) {
  int index = list.locationToIndex(e.getPoint());
  if (index != -1) {
    list.setSelectedIndex(index);
  }
}

代码示例来源:origin: igniterealtime/Spark

/**
 * sets the selected Index using the Point of a given {@link MouseEvent}
 * @param mouseevent - {@link MouseEvent} to get The {@link Point} from
 */
public void setSelectetIndex(MouseEvent mouseevent)
{    
list.setSelectedIndex(list.locationToIndex(mouseevent.getPoint()));
}

代码示例来源:origin: google/sagetv

public void mouseClicked(java.awt.event.MouseEvent e) {
  if (e.getClickCount() == 2) {
   int index = clientList.locationToIndex(e.getPoint());
   MgrServerInfo msi = (MgrServerInfo)currServerList.get(index);
   connectToServer(msi);
  }
 }
};

代码示例来源:origin: stackoverflow.com

private void jListNicknamesMouseClicked(java.awt.event.MouseEvent evt) {                                            
  JList list = (JList)evt.getSource();
  if (evt.getClickCount() == 2) {
    int index = list.locationToIndex(evt.getPoint());
    System.out.println("index: "+index);
  }
}

代码示例来源:origin: xSAVIKx/AndroidScreencast

@Override
  public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
      int index = jListFichiers.locationToIndex(e.getPoint());
      ListModel<Object> dlm = jListFichiers.getModel();
      FileInfo item = (FileInfo) dlm.getElementAt(index);
      launchFile(item);
    }
  }
});

代码示例来源:origin: org.rescarta.rc-cmgr/rc-cmgr

public void mouseReleased(MouseEvent e) {
    if (e.getSource().equals(this.objectJList) && e.isPopupTrigger() && this.objectJList.getSelectedIndex() >= 0) {
      int i = this.objectJList.locationToIndex(e.getPoint());
      this.objectJList.setSelectedIndex(i);
      this.objectJPopupMenu.show(this.objectJList, e.getX(), e.getY());
    }
  }
}

代码示例来源:origin: kaikramer/keystore-explorer

private void maybeAddExtension(MouseEvent evt) {
  if (evt.getClickCount() > 1) {
    int index = jltExtensionTypes.locationToIndex(evt.getPoint());
    extension = jltExtensionTypes.getModel().getElementAt(index);
    isCritical = jcbCriticalExtension.isSelected();
    closeDialog();
  }
}

代码示例来源:origin: mucommander/mucommander

public void mouseClicked(MouseEvent e) {
  // If there was double click on item of the popup's list, 
  // select it, and update the text component.
  if (e.getClickCount() == 2) {
     int index = list.locationToIndex(e.getPoint());
     list.setSelectedIndex(index);
     acceptListItem((String) list.getSelectedValue());
  }
}

代码示例来源:origin: igniterealtime/Spark

public void mousePressed(MouseEvent evt) {
  if (evt.isPopupTrigger()) {
    int index = list.locationToIndex(evt.getPoint());
    list.setSelectedIndex(index);
    ImageIcon icon = (ImageIcon)list.getModel().getElementAt(index);
    String jid = icon.getDescription();
    showPopup(evt, jid);
  }
}

代码示例来源:origin: igniterealtime/Spark

public void mouseReleased(MouseEvent evt) {
    if (evt.isPopupTrigger()) {
      int index = list.locationToIndex(evt.getPoint());
      list.setSelectedIndex(index);
      ImageIcon icon = (ImageIcon)list.getModel().getElementAt(index);
      String jid = icon.getDescription();
      showPopup(evt, jid);
    }
  }
});

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

@Override
 public void mouseClicked( MouseEvent e )
 {
  int iIndex = _list.locationToIndex( e.getPoint() );
  if( iIndex < 0 )
  {
   return;
  }
  _list.setSelectedIndex( iIndex );
  fireSelectionAndDismiss();
 }
}

代码示例来源:origin: org.apache.river.examples/browser

private ServiceListItem getTargetListItem(MouseEvent ev) {
  int index = list.locationToIndex(ev.getPoint());
  if(index >= 0)
    return (ServiceListItem) listModel.getElementAt(index);
  else
    return null;
}
}

代码示例来源:origin: net.java.linoleum/application

private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
if (evt.getClickCount() == 1) {
  open(jList1.locationToIndex(evt.getPoint()));
}
}//GEN-LAST:event_jList1MouseClicked

代码示例来源:origin: org.japura/japura-gui

@Override
 public void mouseMoved(MouseEvent e) {
  listRenderer.mouseOverIndex =
    actionsList.locationToIndex(e.getPoint());
  actionsList.repaint();
 }
});

代码示例来源:origin: org.japura/japura-gui

@Override
 public void mouseMoved(MouseEvent e) {
  listRenderer.mouseOverIndex =
    buttonsList.locationToIndex(e.getPoint());
  buttonsList.repaint();
 }
});

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

public void mousePressed(MouseEvent evt)
  {
    if(evt.isConsumed())
      return;
    int index = markerList.locationToIndex(evt.getPoint());
    markerList.setSelectedIndex(index);
    goToSelectedMarker();
  }
} //}}}

相关文章

JList类方法