How to change background color of the selected item in JList dynamically

后端 未结 4 1720
暗喜
暗喜 2021-02-06 06:32

How can I change the background color of the item which is selected in JList dynamically?

4条回答
  •  后悔当初
    2021-02-06 07:17

    If I am clearly understanding you, look into javax.swing.ListCellRenderer. You need to reimplement it or extend javax.swing.DefaultListCellRenderer and customize the getListCellRendererComponent method.

提交回复
热议问题