[SWING] affichage fenetre corrompu
Salut a tous,
Je me retrouve face à un nouveau probleme.
Je vous explique :
J'ai monté une JFrame pour indiquer une tache en cours d'exécution de type Veuillez patienter un instant.
Mon problème est que lorsque je lance cette fenetre en même temps qu'une tache de fond, cette Frame ne contient plus rien alors que lorsque que je la lance toute seule, c'est nickel!!!
Je pense que ce doit être une question de Thread mais je n'y comprends rien à ces Thread!!!
Quelqu'un pourrait m'aider?
Code:
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 71 72 73 74
|
package leesa;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
public class FenetreInstant extends JFrame
{
private int lEcran, hEcran ;
private JLabel image, instant, text ;
private JPanel pane ;
private Image icon ;
public FenetreInstant(String texte)
{
init(texte);
}
public void init(String texte)
{
java.awt.Image icone = Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("images/myotis.png"));
setIconImage(icone);
this.setUndecorated(true);
this.setSize(250,80);
this.setResizable(false);
getContentPane().setLayout(null);
Border raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
this.pane = new JPanel();
this.pane.setBounds(0,0,250,80);
this.pane.setBorder(raisedetched);
this.icon = Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("images/ajax-loader.gif"));
getContentPane().setLayout(null);
this.image = new JLabel( new ImageIcon(icon));
this.image.setBounds(100,10,image.getWidth(),image.getHeight());
this.image.setLocation(100,10);
this.instant = new JLabel("Veuillez patienter un instant...");
this.instant.setBounds(10,60,120,20);
this.instant.setLocation(10,40);
this.text = new JLabel(texte);
this.text.setBounds(10,80,120,20);
this.text.setLocation(10,60);
pane.add(this.image);
pane.add(this.instant);
pane.add(this.text);
getContentPane().add(pane);
// Centrage de la fenetre
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize(); // Resolution de l'ecran
this.hEcran = (int)(d.getHeight());
this.lEcran = (int)(d.getWidth());
setLocation((lEcran-this.getWidth())/2,(hEcran-this.getHeight())/2);
this.validate();
setVisible(true);
}
} |
PJ : 2 screenShots exemples...