Hi, I am a pretty new programmer, and ran into a situation where I feel pretty stuck. I have a program that involves putting an image on the screen. Currently, I have a static filename: "C:/Program Files..." I want to be able to move a folder with my program and the image around onto multiple computers, but I don't want to have to change the filename every time I do so. Imagine that my the java file is in the same folder as the picture. Is there a method I can call to retrieve the location of file I am running? (If it matters, it is an application)
Please let me know if there is any more information i need to provide.
Thanks in advance for any help you can give.
private class MainPanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2D = (Graphics2D)g;
Image i = Toolkit.getDefaultToolkit().getImage("C:/Program Files/Folder/Picture.jpg");
g2D.drawImage(i, 100, 210, this);}