public void showPopup(MouseEvent e) {
if (!enablePopup) {
return;
}
ActionList actions = null;
JList list = (JList) e.getSource();
int row = list.locationToIndex(e.getPoint());
if (row == -1 || !list.getCellBounds(row, row).contains(e.getPoint())) {
if (list.getSelectedIndex() != -1) {
list.clearSelection();
}
actions = getDefaultActions();
} else {
if (list.getSelectedIndex() != row) {
list.setSelectedIndex(row);
}
actions = getActionsForRow(list, row);
}
if (actions == null || actions.getActionCount() == 0) {
return;
}
JPopupMenu popup = menu == null ? ActionSupport.buildPopup(actions) : menu;
UISupport.showPopup(popup, list, e.getPoint());