当我试图在 上显示图像时JFrame
,它没有被加载。我displayImage(File file)
在扩展类的类中定义了方法JFrame
-
public void displayImage(File file)
{
BufferedImage loadImg = StegImage.loadImage(file);
System.out.println(loadImg.getWidth() + "x" + loadImg.getHeight() + " image is loaded.");
setVisible(true);
setState(JFrame.NORMAL);
setBounds(0, 0, loadImg.getWidth(), loadImg.getHeight());
Graphics2D g = (Graphics2D)getRootPane().getGraphics();
System.out.println("Drawing the image.");
g.drawImage(loadImg, null, 0, 0);
}
我在终端上得到的输出是 -
877 x 587 image is loaded.
Drawing the image.
但在框架中它是不可见的。