there is an error in your code
ImageIcon ii = new ImageIcon(this.getClass().getResource()); image = ii.getImage();
you already name ImageIcon ii, so you need to name the image now maybe iii then you create the image directory in src and you put your pic there, for example sample.png, the code will be
ImageIcon ii = new ImageIcon(getClass().getResource("/src/image/sample.png")); image iii= ii.getImage();
source share