图像 "logo0.gif" 应该放在哪里才能使此代码能够使用它?

Where should the image "logo0.gif" be in order for this code to be able to use it?

public static void main(String [] args)
{
    ImageIcon aLogo = new ImageIcon("Logo0.gif");
    JLabel aLabel = new JLabel(aLogo);
    JPanel aPanel = new JPanel();
    JFrame aFrame = new JFrame();
    aFrame.setSize(740, 320);
    aFrame.add(aPanel);
    aFrame.setVisible(true);
    aPanel.add(aLabel);
    aLabel.setIcon(aLogo);
}

我在这里尝试创建一个 JFrame 来显示图像。但是,当我 运行 此代码在 JFrame 上没有图像时,我相信这是因为文件位置。

aFrame.setVisible(true);
aPanel.add(aLabel);
aLabel.setIcon(aLogo);

应在框架可见之前将组件添加到框架,否则不会调用布局管理器,因此组件的大小为 (0, 0),这意味着没有任何内容可绘制。

此外,请阅读教程并下载演示代码,以更好地构建 class 结构,以便在事件调度线程 (EDT) 上正确创建组件。阅读上述教程中有关 Concurrency in Swing 的部分,了解有关 EDT 及其重要性的更多信息。