bonjour ,
J'ai un problème p'affichage d'image. En effet, j'ai réalisé un splashscreen pour mon application la malheur est que l'image ne s'affiche pas lorsque j'ajoute le thread,.....moi j'ai rien juste un rectangle blanc

CODE
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package splash;
 
import javax.swing.*;
import java.awt.Graphics;
import java.awt.BorderLayout;
import java.awt.Image;
 
 
public class Splash
  extends JWindow {
 
  public Splash(int delay)
  { super();
    JLabel l = new JLabel();
    l.setIcon(new ImageIcon(getClass().getResource("loader.gif")));
    PImage pi = new PImage("splash.png");
    pi.setLayout(new XYLayout());
    pi.add(l, new XYConstraints(150, 110, -1, -1));
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(pi);
    getContentPane().add(p);
    setSize(350, 220);
    setLocationRelativeTo(null);
    setVisible(true);
    try
    { Thread.sleep(delay);
      dispose();
      System.gc();
      }catch (Exception e) {}
  }
 
  class PImage extends JPanel {
    Image img;
    public PImage(String file){
      img = new ImageIcon(getClass().getResource(file)).getImage();
      repaint();
    }
 
    public void paintComponent(Graphics g) {
      super.paintComponent(g);
      if (img == null) return;
      int w = img.getWidth(this);
      int h = img.getHeight(this);
      boolean zoom = (w > getWidth() || h > getHeight());
      if (zoom) g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
      else g.drawImage(img, (getWidth()-w)/2, (getHeight()-h)/2, this);
 
    }
  }
 
}
Merci d'avance pour l'aide que vous pourriez m'apporter