Skip to content
Advertisement

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.

Advertisement

Answer

All that you have to do is this:

label.addMouseListener(new MouseListener())
Advertisement