- jWindow opened for 2 seconds but image doesn't paint... any thoughts?
- image file is in the same folder as class file...
public class CreateSplashScreen extends JWindow {
JWindow jw = new JWindow();
Image scImage = Toolkit.getDefaultToolkit().getImage("testImage.png");
ImageIcon imageIcon = new ImageIcon(scImage);
public CreateSplashScreen() {
try {
jw.setSize(700, 500);
jw.setLocationRelativeTo(null);
jw.setVisible(true);
} catch (Exception e) {
}
}
public void paint(Graphics g) {
super.paint(g);
g.drawImage(scImage, 0, 0, jw);
}
public void CloseSplashScreen() {
jw.setVisible(false);
}
public static void main(String[] args) {
CreateSplashScreen sp = new CreateSplashScreen();
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
Logger.getLogger(CreateSplashScreen.class.getName()).log(Level.SEVERE, null, ex);
}
sp.CloseSplashScreen();
}
}
- jWindow opened for 2 seconds but image doesn't paint... any thoughts?
- image file is in the same folder as class file...
Why are you creating an internal
JWindowwhen your classCreateSplashScreenalready extendsJWindow? There is no need of it. You are messing with your program.How? You are actually viewing the inner
JWindowbyjw.setVisible(true);but you are painting the image in theCreateSplashScreen's `JWindow.Try this code :
Note: I do not know about your method to fetch image resource from the source folder.
Edit: Assuming that the name of the package containing your class
CreateSplashScreeniscreatesplashscreen, make sure that the imagetestImage.pngis present in thecreatesplashscreenpackage of your project.