Bonjour,

Au lancement de mon IHM, j'affiche un Splash Screen, mais le problème est qu'une fois sur deux, quand je lance l'IHM, l'image n'apparait pas, j ai simplement un cadre gris à la place.

J'ai une clase SplashScreenGUI qui extends JWindow, et après recherche, le code à l'air de se bloquer lors de l'appel à setVisible(true) de la classe Component (avant dernière ligne du code, désolée, c'est un peu long) :

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
public SplashScreenGUI() {
        super();
        File lfile = new File("images/splash.gif");
 
        try
        {
            image = ImageIO.read(lfile);
        }
        catch (IOException ioe)
        {
            System.out.println(ioe.getMessage());
        }
 
        // Recuperation des tailles de l'image
        int lImageWidth = image.getWidth();
        int lImageHeight = image.getHeight();
 
        updateText("Lancement Poste Operateur Visuel ...");
        panel.setBackground(new Color(240, 240, 240));
 
        jLabelIcon.setText("");
        jLabelIcon.setBounds(new Rectangle(0, 0, lImageWidth, lImageHeight));
        jLabelIcon.setHorizontalAlignment(SwingConstants.CENTER);
        jLabelIcon.setVerticalAlignment(SwingConstants.CENTER);
        jLabelIcon.setIcon(new ImageIcon("images/splash.gif"));
        panel.add(jLabelIcon, null);
 
        jLabelTitle.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelTitle.setVerticalAlignment(SwingConstants.CENTER);
        jLabelTitle.setHorizontalTextPosition(SwingConstants.CENTER);
        jLabelTitle.setBackground(Color.WHITE);
        panel.add(jLabelTitle, BorderLayout.NORTH);
 
        toFront();
 
        setSize(new Dimension(lImageWidth, lImageHeight + 30));
 
        getContentPane().add(panel, null);
 
        setLocationRelativeTo(null);
        setVisible(true);
 
        Rectangle lwindowRect = panel.getBounds();
 
        splash = new BufferedImage(lImageWidth, lImageHeight, BufferedImage.TYPE_INT_ARGB);
 
        Graphics2D g2 = (Graphics2D) splash.getGraphics();
 
        try
        {
            Robot lRobot = new Robot(getGraphicsConfiguration().getDevice());
            BufferedImage lCapture = lRobot.createScreenCapture(new Rectangle(lwindowRect.x, lwindowRect.y,
                                                                             lwindowRect.width,
                                                                             lwindowRect.height));
 
            g2.drawImage(lCapture, null, 0, 0);
 
        }
        catch (AWTException e)
        {
            e.printStackTrace();
        }
 
        g2.drawImage(image, 0, 0, this);        
 
        setVisible(true);
 
        repaint();
    }
setVisible appelle la méthode show() (dépréciée dans Eclipse 3.1).
Est-ce que le problème peut bien venir de là ?

Si je kill le process de l'IHM et que je relance, l'image apparaît bien et l'IHM se lance, donc je ne comprends pas...

Merci !!!