Search code examples
javaswingjbuttonjlabel

How to use a JLabel as a JButton?


I am trying to make a program that uses a JButton, but the regular button isn't working, so I want to make it so that when I press the JLabel it will activate a function.


Solution

  • All that you have to do is this:

    label.addMouseListener(new MouseListener())