Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1091 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  SplashScreen problème d'affichage d'mage

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

SplashScreen problème d'affichage d'mage

n°1855831
progm
Posté le 27-02-2009 à 08:40:11  profilanswer
 

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 :heink:  
 
CODE

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


SVP j'ai besoin de votre aide

mood
Publicité
Posté le 27-02-2009 à 08:40:11  profilanswer
 

n°1855936
nerisson
Pic-pic
Posté le 27-02-2009 à 13:19:16  profilanswer
 

C'est déjà tout prêt:
http://java.sun.com/docs/books/tut [...] creen.html


---------------
Light is right

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  SplashScreen problème d'affichage d'mage

 

Sujets relatifs
probleme variable flash =>phpProblème conversion chaîne en nombre
Problème d'accentuation... [résolu]Problème de date [résolu]
ASP et access champ memo problemeProblème avec URL rewriting
problème #IND et #INF ,C++[Projet] Problème avec automatisation de bouton
[Pascal / SDL] Problème pour gérer les ThreadsPHP debutant pb avec la syntaxe d'affichage
Plus de sujets relatifs à : SplashScreen problème d'affichage d'mage


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR