@Override public Rectangle getCurrentItemBounds() { int index = myList.getSelectedIndex(); if (index < 0) { LOG.error("No selected element, size=" + getListModel().getSize() + "; items" + getItems()); } Rectangle itmBounds = myList.getCellBounds(index, index); if (itmBounds == null) { LOG.error("No bounds for " + index + "; size=" + getListModel().getSize()); return null; } Point layeredPanePoint = SwingUtilities.convertPoint(myList, itmBounds.x, itmBounds.y, getComponent()); itmBounds.x = layeredPanePoint.x; itmBounds.y = layeredPanePoint.y; return itmBounds; }
private void performMoveUpDown(boolean down) { final int[] indices = myTemplatesList.getSelectedIndices(); if (indices.length == 0) return; final int delta = down ? 1 : -1; myTemplatesList.removeSelectionInterval(0, myConfigurations.size() - 1); for (int i = down ? indices[indices.length - 1] : 0; down ? i >= 0 : i < indices.length; i -= delta) { final int index = indices[i]; final Configuration temp = myConfigurations.get(index); myConfigurations.set(index, myConfigurations.get(index + delta)); myConfigurations.set(index + delta, temp); myTemplatesList.addSelectionInterval(index + delta, index + delta); } final int index = down ? myTemplatesList.getMaxSelectionIndex() : myTemplatesList.getMinSelectionIndex(); final Rectangle cellBounds = myTemplatesList.getCellBounds(index, index); if (cellBounds != null) { myTemplatesList.scrollRectToVisible(cellBounds); } }