[java] cinema.java

Fermé
beta - 23 févr. 2006 à 20:25
arth Messages postés 9374 Date d'inscription mardi 27 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2016 - 7 mars 2006 à 13:39
bonjour,

voila le code que j'ai réalisé en java:


/*
** Created on 22 févr. 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.text.DecimalFormat;


/**
* @author toto
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class cinema extends Applet implements ActionListener {
float Tseance_20;
float Tseance_22;
float Tseance_00;
String [] film;
String [] seance;
String [] status;
float prix_courant;
int flm,sea,sta;
boolean toto;

DecimalFormat df;
String prix_affichage;
Label filmLbl, séanceLbl, statusLbl;
TextField filmTfd, séanceTfd, statusTfd;
Button BBrice_de_nice, BShreck, Ble_cercle, Bséance_20, Bséance_22, Bseance_00,Betudiant,Benfant,Badulte;;
GridLayout g=new GridLayout (5,1);

public void init (){
prix_courant=0;
flm=1;
sea=1;
sta=1;
Tseance_20=6;
Tseance_22=7;
Tseance_00=5;
film= new String [3];
film [0]=new String ("brice de nice");
film [1]=new String ("shreck");
film [2]=new String ("le cercle");
seance=new String [3];
seance [0]=new String ("Séance de 20 heure");
seance [1]=new String ("Séance de 22 heure");
seance [2]=new String ("Séance de 00 heure");
status=new String [3];
status [0]=new String ("Etudiant");
status [1]=new String ("Adulte");
status [2]=new String ("Enfant");
df=new DecimalFormat ("0.00");
filmLbl=new Label ("film:");
filmTfd=new TextField (20);
filmTfd.setEditable(false);

séanceLbl=new Label ("Seance:");
séanceTfd=new TextField (10);
séanceTfd.setEditable(false);
BBrice_de_nice=new Button ("Brice de nice");
BShreck=new Button ("Shreck");
Ble_cercle=new Button ("le cercle");
Bséance_20=new Button ("séance de 20 heure");
Bséance_22=new Button ("séance de 22 heure");
Bseance_00=new Button ("séance de 00 heure");
Betudiant=new Button ("Etudiant");
Badulte=new Button ("Adulte");
Benfant=new Button ("Enfant");
Panel pnl=new Panel();
Panel pnl2=new Panel();
Panel pnl3=new Panel();
Panel pnl4=new Panel();
Panel pnl5=new Panel();
Panel pnl6=new Panel();
pnl.add(filmLbl);
pnl.add(filmTfd);
pnl2.add(séanceLbl);
pnl2.add(séanceTfd);
pnl3.add(statusLbl);
pnl3.add(statusTfd);
pnl4.add(BBrice_de_nice);
BBrice_de_nice.addActionListener(this);
pnl4.add(BShreck);
BShreck.addActionListener(this);
pnl4.add(Ble_cercle);
Ble_cercle.addActionListener(this);
pnl5.add(Bséance_20);
Bséance_20.addActionListener(this);
pnl5.add(Bséance_22);
Bséance_22.addActionListener(this);
pnl5.add(Bseance_00);
Bseance_00.addActionListener(this);
pnl6.setLayout(g);
pnl6.add(pnl);
pnl6.add(pnl2);
pnl6.add(pnl3);
pnl6.add(pnl4);
pnl6.add(pnl5);
add(pnl6);
}
public void actionPerformed(ActionEvent e) {
Button source=(Button)e.getSource();
if(source==BBrice_de_nice){
flm=0;
toto=(true);
}
if(source==BShreck){
flm=1;
toto=true;
}
if(source==Ble_cercle){
flm=2;
toto=true;
}


if(source==Bséance_20){
sea=0;
toto=true;}
if(source==Bséance_22){
sea=1;
toto=true;}
if(source==Bseance_00){
sea=2;
toto=true;}

if(source==Betudiant){
sta=0;
toto=true;}
if(source==Badulte){
sta=1;
toto=true;}
if(source==Benfant){
sta=2;
toto=true;}





filmTfd.setText(film[flm]);
séanceTfd.setText(seance[sea]);
statusTfd.setText(status[sta]);

}

}


en compilant voici j'ai cette erreur:

java.lang.NoSuchMethodError: main
Exception in thread "main"

d'où peut venir cette erreur je vois pas trop.
A voir également:

3 réponses

Utilisateur anonyme
23 févr. 2006 à 21:56
Salut
sans regarder en profondeur ton code source, je l'ai compilé c'est ok.
je pense que tu voulais dire erreur à l'éxécution, dans ce cas c'est normal sans ta fonction "main".
0
je débute en java voici unautre programme :

import java.applet.Applet;
import java.awt.*;

public class login extends Applet
{
Label nomlogin = new Label("login");
TextField login = new TextField(25);
Label password = new Label("password");
TextField pass = new TextField(25);
Button ok = new Button ("OK");


public void init ()
{

add (nomlogin);
add (login);
add (password);
pass.setEchoCharacter('*');
add (pass);
add (ok);

}
}


comment dois je placer le main pour que le programme fonctionne ?
0
arth Messages postés 9374 Date d'inscription mardi 27 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2016 1 292
7 mars 2006 à 13:39
hello

mdr tu serais pas l'iut de clermont toi par hasard?

Bonne journée
0