Showing a counter dynamically for JList items highlighted

后端 未结 1 1490
庸人自扰
庸人自扰 2021-01-27 18:12

I have a program that I created for work. This program takes an uploaded file, reads it, and puts the data into a JList in the GUI. The GUI actually has two lists and the user i

1条回答
  •  一整个雨季
    2021-01-27 18:42

    Register a ListSelectionListener with your JList.

    The listener could simply query how many rows are selected and update the number in the panel to that. Perhaps use getSelectedValues().size().

    http://docs.oracle.com/javase/8/docs/api/javax/swing/JList.html#addListSelectionListener-javax.swing.event.ListSelectionListener-

    0 讨论(0)
提交回复
热议问题