crapaud Profil : Jeune recrue | bonjour!
je creé un petit quizz et j'ai un probleme au niveau de l'attribution d'un point lorsuqe la réponse est bonne sinon c'est 0
voici l'erreur : "l'operateur {0} ne peut pas être appliqué "
qu'est ce que cela veut il dire?
je vous donne le code qui marche :
Code :
- package com.jeu4.test;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.JOptionPane;
- public class Jeu4 extends Frame implements ActionListener
- {
- Frame f;
- CardLayout carte;
- Panel jeu;
- Button bouton=new Button("suivant" );
- Point pt;
- public Jeu4() {
- //panel de la première carte (1ere question)
- Label situation = new Label("quel est le chanteur du groupe Placebo?" );
- Panel p1 = new Panel();
- p1.add(new JRadioButton("Brian Molko" ));
- p1.add(new JRadioButton("Johnny Halliday" ));
- p1.add(new JRadioButton("Jean pascal" ));
- p1.setBackground(Color.orange);
- //panel de la deuxieme carte (2eme question)
- Label situation2 = new Label("qui est 50 cents?" );
- Panel p2 = new Panel();
- p2.add(new JRadioButton("un cycliste" ));
- p2.add(new JRadioButton("Un chanteur" ));
- p2.add(new JRadioButton("Un presentateur TV" ));
- p2.setBackground(Color.green);
- //panel contenant les deux précédents
- jeu=new Panel();
- carte = new CardLayout();
- jeu.setLayout(carte);
- jeu.add("placebo", p1);
- jeu.add("50 cents", p2);
- setLayout(new BorderLayout());
- add("South", bouton);
- add("Center", jeu);
- p1.add("South",situation);
- p2.add("South", situation2);
- bouton.addActionListener(this);
- setVisible(true);
- setBounds(150,150,300,250);
- setTitle("un petit quizz" );
- //String pt = "";
- }
- public void actionPerformed(ActionEvent e) {
- carte.next(jeu);
- {
- if (bouton.getLabel().equals("Brian Molko" ))
- {
- pt += 1;
- }
- }
- }
- public static void main(String[] args) {
- Frame f = new Jeu4();
- }
- }
|
voila!!
merci!! |