Probleme insertion image

developvbdebut Messages postés 476 Date d'inscription samedi 14 août 2004 Statut Membre Dernière intervention 2 juin 2012 - 11 avril 2006 à 09:00
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 - 11 avril 2006 à 13:15
Bonjour tout le monde

J'ai du mal à inserer image des que je mai /.

Car je souhaiterai mettre tout mes image dans un dossier et indiquer le chemin pour l'insertion.

Voici le code.

import java.awt.*;
import java.awt.event.*;
import java.awt.Image;


public class ElementParam extends Panel implements ActionListener
{


int cinpc, dixc, vingtc, cinquc, uneurro;


public ElementParam(Monnayeur m)
{


Label cinp = new Label("5 centimes");


TextField cinpc = new TextField(10);
cinpc.addActionListener(new Stockpiece(5,m));
this.add(cinpc);


Label dix = new Label("10 centimes");


TextField dixc = new TextField(10);
dixc.addActionListener(new Stockpiece(4,m));
this.add(dixc);


Label vingt = new Label("20 centimes");

TextField vingtc = new TextField(10);
vingtc.addActionListener(new Stockpiece(3,m));
this.add(vingtc);


Label cinquante = new Label("50 centimes");


TextField cinquc = new TextField(10);
cinquc.addActionListener(new Stockpiece(2,m));
this.add(cinquc);


Label un = new Label("1 euro");


TextField uneurro = new TextField(10);
uneurro.addActionListener(new Stockpiece(1,m));
this.add(uneurro);





Button valide = new Button("Valider");
valide.addActionListener(this);


Image quit=getImage(getDocumentBase(),"machine_a_cafe/image/fermerparam.JPEG");
Label bquit = new Label(new ImageIcon(quit));


}


}



Voici les erreur maintenant

ElementParam.java:52: cannot find symbol
symbol : method getDocumentBase()
location: class ElementParam
Image quit=getImage(getDocumentBase(),"machine_a_cafe/image/fermerparam.JPEG");
^
ElementParam.java:53: cannot find symbol
symbol : class ImageIcon
location: class ElementParam
Label bquit = new Label(new ImageIcon(quit));
^

Que dois je faire svp?

Merci

Cordialement

A bientôt

5 réponses

bloofi Messages postés 388 Date d'inscription mercredi 1 octobre 2003 Statut Membre Dernière intervention 3 mai 2006 2
11 avril 2006 à 11:36
coucou,

essaye comme ca :
Label bquit = new Label(new ImageIcon("machine_a_cafe/image/fermerparam.JPEG"));
0
developvbdebut Messages postés 476 Date d'inscription samedi 14 août 2004 Statut Membre Dernière intervention 2 juin 2012 1
11 avril 2006 à 12:21
Salut

Il refuse bloofi voici l'erreur qu'il me sort

ElementParam.java:58: cannot find symbol
symbol : constructor Label(javax.swing.ImageIcon)
location: class java.awt.Label
Label quit = new Label(new ImageIcon("machine_a_cafe/image/fermerparam.JPEG"));


J'ai l'impression qu'il refuse le label.

A+
0
bloofi Messages postés 388 Date d'inscription mercredi 1 octobre 2003 Statut Membre Dernière intervention 3 mai 2006 2
11 avril 2006 à 12:51
essaye avec un JLabel :

JLabel quit = new JLabel(new ImageIcon("machine_a_cafe/image/fermerparam.JPEG"));
0
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
11 avril 2006 à 13:13
Salut,



il ne me semble pas qu'en awt tu puisses mettre des images dans un label encore moins dans le constructeur :




Constructor Summary,

----

Label()


Constructs an empty label.,

----

Label(String text)


Constructs a new label with the specified string of text,
left justified.,

----

Label(String text,
int alignment)


Constructs a new label that presents the specified string of
text with the specified alignment.









essaye plutot avec swing qui est beaucoup plus évolué graphiquement qu'awt


Constructor Summary,

----

JLabel()


Creates a
JLabel
instance with
no image and with an empty string for the title.,

----

JLabel(Icon image)


Creates a
JLabel
instance with the specified image.,

----

JLabel(Icon image,
int horizontalAlignment)


Creates a
JLabel
instance with the specified
image and horizontal alignment.,

----

JLabel(String text)


Creates a
JLabel
instance with the specified text.,

----

JLabel(String text,
Icon icon,
int horizontalAlignment)


Creates a
JLabel
instance with the specified
text, image, and horizontal alignment.,

----

JLabel(String text,
int horizontalAlignment)


Creates a
JLabel
instance with the specified
text and horizontal alignment.


WORA
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Twinuts Messages postés 5375 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 14 juin 2023 111
11 avril 2006 à 13:15
J'oublié il va te falloir basculer toute ton appli en swing si tu
utilise un de ses composant (les conteneurs awt support mal le melange)

WORA
0
Rejoignez-nous