I want to add images to JButtons. Here is the code I am using:
The images are in a folder called “Images”, which happens to be in the source package of the application. The size of the JButtons is adjusted correctly, however no image is displayed in the button. Can someone help me solve this problem please? Thanks 🙂
Try
create_ImageIcon(Button_NewFile, "src/Images/New File.png");When you create an
ImageIcon, it searches for relative paths where the application is launched. Normally this is in the folder where src folder is located. But have in mind that when you run it as an independent application.