图像未显示在 JLayeredPane 内的 JLabel 中

问题描述

我正在尝试编写一些代码,在 JlayeredPane 的底层显示图像图标。我已将代码设置为首先将图像作为 BufferedImage,然后将其转换为 ImageIcon。我的图像在我的项目文件夹中(见屏幕截图),但是当我运行代码时,框架中没有任何显示

    try {
         image = ImageIO.read(new File("stave.png"));
         stave = new ImageIcon(image,"An image of a musical stave");
    } catch(IOException ex){
        System.out.println("image input failure");
    }
    
    stave_holder = new JLabel(stave);
    
    lp = new JlayeredPane();
    lp.setSize(1000,300);
    lp.add(stave_holder,0);//depth of 0,all other components will sit on top of this component

screenshot

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)