I'm trying to import images into my eclipse project. Right now, to assign an image to a BufferedImage I'm using:
try{
player = ImageIO.read(new File(javax.swing.filechooser.FileSystemView.getFileSystemView().getHomeDirectory() + "\\"));
} catch (Exception e){
e.printStackTrace();
}
I have to get the path of the users Desktop, and the user of the game has to put the game and the images on their desktop, and it's just very annoying.
Question - How can I import an image into my eclipse project so I can just use:
new File("filename.png");
and the image will export with the project jar, and still work?
Note - I'm tried this in the past by putting the image into the src folder or the Project folder, but I think I broke something in my Eclipse where it's not recognizing pngs as pngs.
In the import selection panes, use the following methods to select exactly the resources you want to add:
4.1 Expand the hierarchies in the left pane and select or clear the checkboxes that represent the folders in the selected directory. Then in the right pane, select or clear checkboxes for individual files.
4.2 Click Filter Types to filter the current selection for files of a specific type.
4.3 Click Select All to select all resources in the directory, then go through and deselect the ones that you do not want to add.
4.4 Click Deselect All to deselect all resources in the directory, then go through and choose individual resources to add.
Specify the Workbench project or folder that will be the import destination.
Reference: eclipse