Make JLabel background transparent again

前端 未结 2 955
面向向阳花
面向向阳花 2020-12-06 19:20

I have a JLabel that changes its background color when the mouse enters it. The problem I have is that I want the JLabel to become transparent after the mouse exits.

2条回答
  •  孤城傲影
    2020-12-06 19:35

    JLabel is by default transparent and non-opaque, if you want to change background on mouse exit, then you have to:

    • setBackground() for both states, enter and exit

    • change to JPanel or another JComponent

提交回复
热议问题