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()); }
private UniProfile isSameProfile(String name) { int size = model.getSize(); for (int i = 0; i < size; i++) { UniProfile aProfile = (UniProfile) model.getElementAt(i); if (aProfile.toString().equals(name)) return aProfile; } return null; }