Article View: borland.public.jbuilder.java.swing
Article #9197JPanel + images
From: JPBallet
Date: Thu, 11 May 2000 00:00
Date: Thu, 11 May 2000 00:00
96 lines
3297 bytes
3297 bytes
Hello,
my system: Windows NT4, JBuilder3.0.
i have two class:
public class CadreExpo extends JFrame {
........
JPanel jPanel2 = new JPanel();
.........
//Construire le cadre
public CadreExpo() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
ChoixLangue.setLangue("FRAN");
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
////////////////////////////////////////
///////////////////////////////////////
jPanel12.add(new CadreAffichePicto()); or jPanel12.add(new
CadreAffichePicto(jPanel12));
///////////////////////////////////////
/////////////////////////////////////
}
...........
........
}
An an another class CadreAffichePicto at which i load two pictures :a map
and a pictogram above.
public class CadreAffichePicto extends JPanel {
MediaTracker tracker; Image picImage =null;
Image fondCarte= null;
//TransparentImage jPan;
private JPanel jPan;
//BorderLayout borderLayout1 = new BorderLayout();
public CadreAffichePicto() {
construireCarte();
}
public CadreAffichePicto(JPanel _jPan) {
// Il faudra mettre le ou les picto avec leurs positions respectives
jPan=_jPan;
construireCarte();
}
public void construireCarte() {
tracker = new MediaTracker(this);
// onajoute au tracker le fond de la carte
String prefix1 = System.getProperty("user.dir") +
System.getProperty("file.separator")
+ "image"
+System.getProperty("file.separator")
+ "cartes"
+System.getProperty("file.separator")
+ "Arcalpi.gif";
fondCarte= getToolkit().getImage(prefix1);
tracker.addImage(fondCarte, 0);
// Puis les pico
String prefix2 = System.getProperty("user.dir") +
System.getProperty("file.separator")
+ "image"
+System.getProperty("file.separator")
+ "picto"
+System.getProperty("file.separator")
+ "P2.gif";
picImage=getToolkit().getImage(prefix2);
tracker.addImage(picImage, 0);
// puis on rajoute
repaint();
}
public void paint(Graphics gc)
if(picImage != null && fondCarte != null) {
if(g.drawImage(fondCarte, 0,0,this) == false)
System.out.println("Fond carte FALSE");
if(g.drawImage(picImage,10,100,this) == false)
System.out.println("Image FALSE");
}
}
}
Why i can't load and display correctly the CadreAffichePicto from the
CadreExpo class
what is wrong!!
Thank you for your help!!
Jean-Pierre Ballet
Technical Details
Message-ID:
<8fe9js$nl76@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,943ecd5ebf895d8f,start X-Google-Attributes: gid111d45,public From: "JPBallet" <jean-pierre.ballet@meteo.fr> Subject: JPanel + images Date: 2000/05/11 Message-ID: <8fe9js$nl76@bornews.borland.com> X-Deja-AN: 622089719 Organization: METEO-FRANCE X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: borland.public.jbuilder.java.swing