Reputation: 345
How can I edit an item from a Jlist by simply adding an integer after that specific item (something like an append) ? Adding items to jlist with addbuttonlistener work fine but I don't know how can I edit them .
Upvotes: 1
Views: 5142
Reputation: 121
I think you can used
int x = txtList.getSelectedIndex();
if (x >= 0) {
listModel.remove(x);
txtList.setModel(listModel);
}
txtlist is your jlist name. First, you should declare listmodel. if have problem , you can contact me to discus
Upvotes: 0
Reputation: 128807
One solution is to use a JTable
with a single column. Then you can use a CellEditor. See more about JTable
and CellEditors on How to use Tables.
Upvotes: 4