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

后端 未结 4 1722
暗喜
暗喜 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:07

     jList1.setSelectedIndex(currentLine);
     jList1.setSelectionBackground(Color.red);
    

    Just Set Selected index of all the items you want to color in a loop and Change the color Accordingly!

提交回复
热议问题