This program will help you to change the images while you hover your cursor over the jLabel.

Make two methods. In this case, let’s say showImage1() and showImage11().

Insert the following codes inside those methods.

ImageIcon icon = neImageIcon(getClass().getResource(“/Images/icons8-inbox-100.png“));

        Image imageicon.getImage().getScaledInstance(jLabel1.getWidth(),     jLabel1.getHeight(), Image.SCALE_SMOOTH);

        jLabel1.setIcon(new ImageIcon(image));

The highlighted path is the image path.

Then right click on the jLabel and Events->Mouse->Mouse Entered

And type showImage1().

Then right click on the jLabel and Events->Mouse->Mouse Exited

And type showImage11(). Then run the program and enjoy!

Here is the zip for the project.

Author

Write A Comment