java 程序的图片要输入到哪里?

Where do I put images for java program to input?

我一直在按照一个教程来学习图形,在一个程序中,作者使用图像制作纹理涂料。我已经复制了他的代码,但是我不知道将图像实际放在哪里以供阅读。我曾尝试在 eclipse 中创建一个资源文件夹并将其设置为源文件夹构建路径,但这没有用。代码如下:

编辑: 好的,我发现它正在从 class 的来源拍摄图像。但是,假设我想从我的桌面或硬盘驱动器上的其他位置提取图像,我该怎么做?

class Surface extends JPanel {

    private BufferedImage slate;
    private BufferedImage java;
    private BufferedImage pane;
    private TexturePaint slatetp;
    private TexturePaint javatp;
    private TexturePaint panetp;

    public Surface() {

        loadImages();
    }

    private void loadImages() {

        try {

            slate = ImageIO.read(new File("slate.png"));
            java = ImageIO.read(new File("java.png"));
            pane = ImageIO.read(new File("pane.png"));



 } catch (IOException ex) {

        Logger.getLogger(Surface.class.getName()).log(
                Level.SEVERE, null, ex);
    }
}

private void doDrawing(Graphics g) {

    Graphics2D g2d = (Graphics2D) g.create();

    slatetp = new TexturePaint(slate, new Rectangle(0, 0, 90, 60));
    javatp = new TexturePaint(java, new Rectangle(0, 0, 90, 60));
    panetp = new TexturePaint(pane, new Rectangle(0, 0, 90, 60));

    g2d.setPaint(slatetp);
    g2d.fillRect(10, 15, 90, 60);

    g2d.setPaint(javatp);
    g2d.fillRect(130, 15, 90, 60);

    g2d.setPaint(panetp);
    g2d.fillRect(250, 15, 90, 60);

    g2d.dispose();
}

@Override
public void paintComponent(Graphics g) {

    super.paintComponent(g);
    doDrawing(g);
}

}

This 会有所帮助。
或者只使用绝对路径来归档。 linux: /home/user/... 窗口: C:/Users/..