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

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

    An easier way would be to go to design mode in Eclipse, and in the properties of your JList, click on the button that has two small arrows with a big yellow arrow inbetween to open up "show advanced properties." then scroll down and change the color where it says "selectionBackground" and change the color there (it will probably be gray, but it will still change). Now, when you run your program, whatever you select, the background will be that color.

提交回复
热议问题