intellij doesn't display image

Answered
hi! am new to java and intellij.
i am trying to display two images on splashscreen, but when i run it only empty screen appears.
no idea why is that... thanks!

import javax.swing.*;
import java.awt.*;

public class SplashScreen {
JFrame frame;//Creating object of JFrame
JLabel image = new JLabel(new ImageIcon("C:/Users/Handuha/IdeaProjects/myApp/src/myApp/SplashScreen.png"));
JLabel image2 = new JLabel(new ImageIcon("C:/Users/Handuha/IdeaProjects/myApp/src/myApp/ajax-loader.gif"));


public SplashScreen()//Creating constructor of the class
{
createGUI();
addImage();
addImage();
}

private void createGUI() {
frame = new JFrame();
frame.getContentPane().setLayout(null);//setting layout to null
frame.setUndecorated(true);//Turning off Title bar
frame.setSize(500, 650);//Setting size
frame.setLocationRelativeTo(null);//Setting location to the center of screen
frame.getContentPane().setBackground(Color.lightGray);//setting background color
frame.setVisible(true);//setting visibility
}

private void addImage() {
image.setBounds(40, 20, 400, 500);
frame.add(image);//Adding image to the frame
image2.setBounds(230, 580, 50, 50);
frame.add(image2);
}

}
1 comment
Comment actions Permalink

Please ask generic Swing/Java questions on Stackoverflow, this forum is specific to IntelliJ Platform SDK. Thanks.

1

Please sign in to leave a comment.