Help svp!!! applet fonctionne avec applet viewer mais pas dans une page html
cs_alala
Messages postés10Date d'inscriptionmercredi 22 septembre 2004StatutMembreDernière intervention29 juillet 2005
-
16 juin 2005 à 18:36
JavaNerd
Messages postés14Date d'inscriptionmardi 14 octobre 2003StatutMembreDernière intervention22 juin 2005
-
17 juin 2005 à 08:50
Bonjour tt le monde!!!
J'ai vraiment besoin d'aide.
Je débute en java avec JBuilderX.
Je dois réaliser un projet dont un des but est de lire des valeurs dans un fichier texte. Ces valeurs sont de la forme "x;x;x;x" où "x" représente la valeur "0" ou "1". En fonction de la valeur de "x", un jRadioBouton doit réagir. par exemple, si "x" prend la valeur "1", le jRadioBouton correspondant doit s'activer et se cocher.
J'arrive parfaitement à lire dans ce fichier et à faire réagir les jRadioBouton.
Cependant, quand je lance l'applet à partir de la page html, rien ne se passe, alors qu'avec l'applet viewer tout marche nikel :
kk1 pourrait-il me dire d'où vient l'erreur? parsk là je nage complètement et je commence à déprimer .
On ma dit ke c pe-etr un pb de path des fichiers et kil fo utiliser com url de mon fichier :
MaClass.class.getClassLoader().getResource("./data.txt");
Cette ligne de code à l'air pas mal, mais je vois pas où il faut la mettre.....
Je mets mon code. Si kk1 pouvais me dire ske je dois changer ce serait génial, parsk je dois finir ce projet en urgence.
N.B. : la méthode pr lire le fichier texte se trouve vers la fin.
EtageDestination0.setBackground(Color.white);
EtageDestination0.setEnabled(false);
EtageDestination0.setText("Étage 0");
EtageDestination1.setBackground(Color.white);
EtageDestination1.setEnabled(false);
EtageDestination1.setText("Étage 1");
EtageDestination2.setBackground(Color.white);
EtageDestination2.setEnabled(false);
EtageDestination2.setText("Étage 2");
EtageDestination3.setBackground(Color.white);
EtageDestination3.setEnabled(false);
EtageDestination3.setDoubleBuffered(false);
EtageDestination3.setFocusPainted(true);
EtageDestination3.setText("Étage 3");
EtageActuel0.setBackground(Color.white);
EtageActuel0.setEnabled(false);
EtageActuel0.setText("Étage 0");
EtageActuel1.setBackground(Color.white);
EtageActuel1.setEnabled(false);
EtageActuel1.setText("Étage 1");
EtageActuel2.setBackground(Color.white);
EtageActuel2.setEnabled(false);
EtageActuel2.setText("Étage 2");
EtageActuel3.setBackground(Color.white);
EtageActuel3.setEnabled(false);
EtageActuel3.setText("Étage 3");
panel1.setBackground(Color.black);
PorteOuverte3.setBackground(Color.white);
PorteOuverte3.setEnabled(false);
PorteOuverte3.setText("Ouverte");
PorteFermee3.setBackground(Color.white);
PorteFermee3.setEnabled(false);
PorteFermee3.setText("Fermée");
panel2.setBackground(Color.black);
PorteOuverte2.setBackground(Color.white);
PorteOuverte2.setEnabled(false);
PorteOuverte2.setText("Ouverte");
PorteFermee2.setBackground(Color.white);
PorteFermee2.setEnabled(false);
PorteFermee2.setText("Fermée");
PorteOuverte1.setBackground(Color.white);
PorteOuverte1.setEnabled(false);
PorteOuverte1.setText("Ouverte");
PorteFermee1.setBackground(Color.white);
PorteFermee1.setEnabled(false);
PorteFermee1.setText("Fermée");
PorteOuverte0.setBackground(Color.white);
PorteOuverte0.setEnabled(false);
PorteOuverte0.setText("Ouverte");
PorteFermee0.setBackground(Color.white);
PorteFermee0.setEnabled(false);
PorteFermee0.setText("Fermée");
panel3.setBackground(Color.black);
panel4.setBackground(Color.black);
panel5.setBackground(Color.black);
VoyantAllume3.setBackground(Color.white);
VoyantAllume3.setEnabled(false);
VoyantAllume3.setText("Allumé");
VoyantEteint3.setBackground(Color.white);
VoyantEteint3.setEnabled(false);
VoyantEteint3.setText("Éteint");
VoyantAllume2.setBackground(Color.white);
VoyantAllume2.setEnabled(false);
VoyantAllume2.setText("Allumé");
VoyantEteint2.setBackground(Color.white);
VoyantEteint2.setEnabled(false);
VoyantEteint2.setText("Éteint");
VoyantAllume1.setBackground(Color.white);
VoyantAllume1.setEnabled(false);
VoyantAllume1.setText("Allumé");
VoyantEteint1.setBackground(Color.white);
VoyantEteint1.setEnabled(false);
VoyantEteint1.setText("Éteint");
VoyantAllume0.setBackground(Color.white);
VoyantAllume0.setEnabled(false);
VoyantAllume0.setText("Allumé");
VoyantEteint0.setBackground(Color.white);
VoyantEteint0.setEnabled(false);
VoyantEteint0.setText("Éteint");
panel6.setBackground(Color.black);
panel7.setBackground(Color.black);
panel8.setBackground(Color.black);
Urgence1.setBackground(Color.white);
Urgence1.setEnabled(false);
Urgence1.setText("");
Urgence2.setBackground(Color.white);
Urgence2.setEnabled(false);
Urgence2.setText("");
Urgence3.setBackground(Color.white);
Urgence3.setEnabled(false);
Urgence3.setText("");
panel9.setBackground(Color.lightGray);
panel10.setBackground(Color.lightGray);
xYLayout1.setWidth(708);
xYLayout1.setHeight(450);
jLabel6.setFont(new java.awt.Font("Dialog", 0, 10));
jLabel6.setText("Choisissez l\'étage de destination");
AllerEtage3.setSelected(false);
AllerEtage3.setText("3");
AllerEtage3.addMouseListener(new Applet_Ascenseur_AllerEtage3_mouseAdapter(this));
AllerEtage2.setText("2");
AllerEtage2.addMouseListener(new Applet_Ascenseur_AllerEtage2_mouseAdapter(this));
AllerEtage1.setText("1");
AllerEtage1.addMouseListener(new Applet_Ascenseur_AllerEtage1_mouseAdapter(this));
AllerEtage0.setText("0");
AllerEtage0.addMouseListener(new Applet_Ascenseur_AllerEtage0_mouseAdapter(this));
Stop.setText("STOP");
Stop.addMouseListener(new Applet_Ascenseur_Stop_mouseAdapter(this));
Urgence.setText("URGENCE");
Urgence.addMouseListener(new Applet_Ascenseur_Urgence_mouseAdapter(this));
this.add(jLabel4, new XYConstraints(334, 166, 135, 36));
this.add(jLabel3, new XYConstraints(170, 166, 123, 36));
this.add(jLabel2, new XYConstraints(23, 166, 99, 35));
this.add(jLabel1, new XYConstraints(145, 11, 163, 33));
this.add(EtageDestination3, new XYConstraints(192, 54, -1, -1));
this.add(EtageDestination0, new XYConstraints(192, 123, -1, -1));
this.add(EtageDestination1, new XYConstraints(192, 100, -1, -1));
this.add(EtageDestination2, new XYConstraints(192, 77, -1, -1));
this.add(EtageActuel3, new XYConstraints(39, 218, -1, -1));
this.add(EtageActuel0, new XYConstraints(39, 287, -1, -1));
this.add(EtageActuel1, new XYConstraints(39, 264, -1, -1));
this.add(EtageActuel2, new XYConstraints(39, 241, -1, -1));
this.add(jLabel5, new XYConstraints(184, 357, 99, 39));
this.add(Urgence2, new XYConstraints(219, 402, -1, -1));
this.add(Urgence1, new XYConstraints(198, 402, -1, -1));
this.add(Urgence3, new XYConstraints(240, 402, -1, -1));
this.add(panel1, new XYConstraints(226, 215, 1, 100));
this.add(PorteFermee3, new XYConstraints(226, 218, -1, -1));
this.add(panel2, new XYConstraints(160, 241, 127, 1));
this.add(PorteFermee2, new XYConstraints(226, 242, -1, -1));
this.add(panel3, new XYConstraints(161, 265, 126, 1));
this.add(PorteFermee1, new XYConstraints(227, 266, -1, -1));
this.add(panel4, new XYConstraints(160, 289, 127, 1));
this.add(PorteFermee0, new XYConstraints(227, 290, -1, -1));
this.add(VoyantEteint3, new XYConstraints(405, 217, -1, -1));
this.add(panel5, new XYConstraints(404, 216, 1, 97));
this.add(panel6, new XYConstraints(346, 240, 110, 1));
this.add(VoyantEteint2, new XYConstraints(405, 241, -1, -1));
this.add(panel7, new XYConstraints(346, 264, 110, 1));
this.add(VoyantEteint1, new XYConstraints(405, 265, -1, -1));
this.add(panel8, new XYConstraints(346, 288, 111, 1));
this.add(VoyantEteint0, new XYConstraints(405, 289, -1, -1));
this.add(panel9, new XYConstraints(21, 151, 441, 7));
this.add(panel10, new XYConstraints(19, 336, 441, 7));
this.add(VoyantAllume3, new XYConstraints(342, 218, -1, -1));
this.add(VoyantAllume2, new XYConstraints(342, 242, -1, -1));
this.add(VoyantAllume1, new XYConstraints(342, 265, -1, -1));
this.add(VoyantAllume0, new XYConstraints(342, 289, -1, -1));
this.add(PorteOuverte3, new XYConstraints(156, 218, -1, -1));
this.add(PorteOuverte2, new XYConstraints(156, 242, -1, -1));
this.add(PorteOuverte1, new XYConstraints(155, 266, -1, -1));
this.add(PorteOuverte0, new XYConstraints(156, 290, -1, -1));
this.add(AllerEtage1, new XYConstraints(600, 74, 41, 31));
this.add(AllerEtage0, new XYConstraints(643, 74, 43, 31));
this.add(jLabel6, new XYConstraints(520, 22, 163, 37));
this.add(Stop, new XYConstraints(564, 120, 78, 36));
this.add(Urgence, new XYConstraints(536, 182, 142, 50));
this.add(AllerEtage2, new XYConstraints(555, 74, 41, 31));
this.add(AllerEtage3, new XYConstraints(508, 74, -1, 31));
}
//Start the applet
public void start() {
}
//Stop the applet
public void stop() {
}
//Destroy the applet
public void destroy() {
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
/******************************************************************/
/* classe permettant de gérer l'évènement du bouton "AllerEtage3" */
/******************************************************************/
class Applet_Ascenseur_AllerEtage3_mouseAdapter
extends java.awt.event.MouseAdapter {
Applet_Ascenseur adaptee;
/******************************************************************/
/* classe permettant de gérer l'évènement du bouton "AllerEtage2" */
/******************************************************************/
class Applet_Ascenseur_AllerEtage2_mouseAdapter
extends java.awt.event.MouseAdapter {
Applet_Ascenseur adaptee;
/******************************************************************/
/* classe permettant de gérer l'évènement du bouton "AllerEtage1" */
/******************************************************************/
class Applet_Ascenseur_AllerEtage1_mouseAdapter
extends java.awt.event.MouseAdapter {
Applet_Ascenseur adaptee;
/******************************************************************/
/* classe permettant de gérer l'évènement du bouton "AllerEtage0" */
/******************************************************************/
class Applet_Ascenseur_AllerEtage0_mouseAdapter extends java.awt.event.MouseAdapter {
Applet_Ascenseur adaptee;
/***********************************************************/
/* classe permettant de gérer l'évènement du bouton "Stop" */
/***********************************************************/
class Applet_Ascenseur_Stop_mouseAdapter
extends java.awt.event.MouseAdapter {
Applet_Ascenseur adaptee;
/**************************************************************/
/* classe permettant de gérer l'évènement du bouton "Urgence" */
/**************************************************************/
class Applet_Ascenseur_Urgence_mouseAdapter
extends java.awt.event.MouseAdapter {
Applet_Ascenseur adaptee;
StringTokenizer tok = new StringTokenizer(LigneLue, ";");
int nv = tok.countTokens();
int i = nv;
int x;
int Tab[] = new int[i];
for (i = 0; i < nv; i++) {
x = Integer.parseInt(tok.nextToken());
System.out.println(x);
Tab[i] = x;
}
JavaNerd
Messages postés14Date d'inscriptionmardi 14 octobre 2003StatutMembreDernière intervention22 juin 2005 17 juin 2005 à 08:50
Bonjour
Je pense avoir la réponse à ton problème.
Il faut en effet savoir qu'une applet ne peut en aucun cas accéder au
système de fichier de l'ordinateur client sur laquelle elle
s'execute, Lors de son développement SUN à volontairement
vérrouiller l'accés au système de fichier pour éviter un trou
majeure de sécurité.
Donc tu ne peux malheureusement pas accéder à ton fichier avec une applet c'est interdit!!!