Draw a JButton to look like a JLabel (or at least without the button edge?)

前端 未结 5 1449
野的像风
野的像风 2020-12-14 18:43

I\'ve got a JButton that for various reasons I want to act like a button, but look like a JLabel. It doesn\'t actually have to be a JLabel under the hood, I just don\'t wan

5条回答
  •  一生所求
    2020-12-14 18:53

     setContentAreaFilled(false);
     setBorderPainted(false);
     setOpaque(false);
    

    This three lines do the trick.

提交回复
热议问题