Beispiel #1
0
 void profileList_mouseClicked(MouseEvent e) {
   JList theList = (JList) e.getSource();
   ListModel aModel = theList.getModel();
   int index = theList.locationToIndex(e.getPoint());
   if (index < 0) return;
   UniProfile aProfile = (UniProfile) aModel.getElementAt(index);
   nameTextField.setText(aProfile.toString());
 }
    public void mouseClicked(MouseEvent evt) {
      // Note: we can't depend on evt.getSource() because of backward
      // compatability
      if (list != null && SwingUtilities.isLeftMouseButton(evt) && (evt.getClickCount() % 2 == 0)) {

        int index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint());
        if (index >= 0) {
          File f = (File) list.getModel().getElementAt(index);
          try {
            // Strip trailing ".."
            f = ShellFolder.getNormalizedFile(f);
          } catch (IOException ex) {
            // That's ok, we'll use f as is
          }
          if (getFileChooser().isTraversable(f)) {
            list.clearSelection();
            changeDirectory(f);
          } else {
            getFileChooser().approveSelection();
          }
        }
      }
    }