Goal
What I want to do is to set a MouseListener on a Panel when click on a Button1. Then I want to click on another Button that changes the MouseListener code to do something else.
Example of application
- Click on JButton1 -> add MouseListener that change a JLabel background color to red.
- Click on JButton2 -> DOESNT ADD a new MouseListener, but change the first one to set the JLabel text to "hello world"
What I can't do
I don't know how to modify an UNIQUE MouseListener.
What I tried
I tried to set an jButton.actionPerformed( new jLabel1.addMouseListener()) for each button, but they create two instance of MouseListener.
I don't want to set one MouseListener for several JButtons, but several JButton changing the status of my MouseListener.
Thanks alot :)