How do I drag and drop a row in a JTable?
问题 How do you setup a JTable to be able to drag a row to a different index in the table. For example if I have 5 rows and I want to drag the 4th row to the 2nd position? 回答1: Check out the drag and drop section of the Java Tutorial. There are some examples on how to implement this for JTable . 回答2: The following allows JTable re-ordering of a single dragged row: table.setDragEnabled(true); table.setDropMode(DropMode.INSERT_ROWS); table.setTransferHandler(new TableRowTransferHandler(table)); Your