Hello lovely people,

I created an application in which I use pictures to create background and other things. But when i send my application to someone so they can have a look at it, the image are not displayed. I know why they are not displaying(the image directory isn't the same for other computers) but i do not know how to fix this.

I'm using these following line to get my images:

Image backgroundImg = Toolkit.getDefaultToolkit().getImage("C:\\Users\\Taimoor\\Documents\\NetBeansProjects\\Menu\\src\\menu\\SHMBG2SHM.jpg");
    Image ballImg = Toolkit.getDefaultToolkit().getImage("C:\\Users\\Taimoor\\Documents\\NetBeansProjects\\Menu\\src\\menu\\SHMBallSHM.gif");

Suggestions?

Thank you in Advance

Pack the images into the jarfile with the app and use ImageIO and getResourceAsStream.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.