我建议将其添加为 ImageIcon:
ImageIcon image = new ImageIcon("image.jpeg");
add(image);
Run Code Online (Sandbox Code Playgroud)
编辑(如何添加它添加特定坐标):
首先要注意的是,通常(99% 的情况)不鼓励您自己定位 JComponent。使用 LayoutManager 为您定位它们,并处理调整大小。
我会告诉你如何自己定位:
null:setLayout(null)。ImageIcon为特定坐标:image.setLocation(x, y)。