public static void moveSelectedRow(@NotNull JTree tree, int direction) {
    TreePath selectionPath = tree.getSelectionPath();
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)selectionPath.getLastPathComponent();
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode)treeNode.getParent();
    int idx = parent.getIndex(treeNode);
    if (idx + direction < 0 || idx + direction >= parent.getChildCount()) {
      return;
    }
    DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
    model.removeNodeFromParent(treeNode);
    model.insertNodeInto(treeNode, parent, idx + direction);
    selectNode(tree, treeNode);
  }
public static void moveSelectedRow(@NotNull JTree tree, int direction)