问题
I have a JList populated with Strings. I want to be able to edit an item by double clicking on it and then edit its text in the JList itself. So if I click an item, then it's highlighted and I see the cursor, then for example I delete the text and write something else. Then I click enter and the text is edited successfully. Is that possible & how can I do this please? I really need this.
回答1:
See List Editor for a couple of solutions, one is to just use a JTable, the other is to create a custom edit Action for the JList.
来源:https://stackoverflow.com/questions/19212232/how-to-edit-a-jlist-item-text-by-double-clicking-on-it