通过url的图像不显示

1l5u6lss  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(272)
import java.awt.*;
import javax.swing.*;

public class O2BIntro extends Open2Beat {

    private JLabel screenGraphic;

    private ImageIcon introBackground;
    private ImageIcon titleImage;
    private ImageIcon startButtonImg;
    private ImageIcon settingButtonImg;
    private ImageIcon buttonSelectedImg;

    public O2BIntro() {
        introBackground = new ImageIcon(this.getClass().getResource("../img/wp2537453-dj-background-hd.jpg"));
        titleImage = new ImageIcon(this.getClass().getResource("src/img/open2BeaTTitle.png"));
        startButtonImg = new ImageIcon(this.getClass().getResource("src/img/MenuImg_Gamestart_KR.png"));
        settingButtonImg = new ImageIcon(this.getClass().getResource("src/img/MenuImg_Preference_KR.png"));

    }

    public void paintIntro() {

        screenGraphic = new JLabel(introBackground,JLabel.CENTER);
        screenGraphic.setBounds(0, 0, DisplayBasic.myScreenWidth, DisplayBasic.myScreenHeight);
        add(screenGraphic);
    }

}

所以,这是我目前的部分代码。我试图从/src/img/加载我的图像,但它仍然没有显示任何内容。我应该如何编辑我的代码?我应该使用哪种框架或组件来正确显示?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题