Home » Java » java – Why are my images not appearing on top of my JButtons?-Exceptionshub

java – Why are my images not appearing on top of my JButtons?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying to make Battleship in Java, and am using a custom class that is an extension of the JButton class to make interactable grid tiles. I have set the ship sprites, which are JLabels, to be on a JLayeredPane so they appear on top. However, they never appear no matter what I do. A copy of my current(and messy, I’ll polish it up later) project can be found here.

The grid tiles are created in the constructor method, and the sprites are handled in the ActionListener class. Can someone please explain why I never see the JLabels on top?

How to&Answers: