1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
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");
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");
int score;
}
public void actionPerformed(ActionEvent e) {
carte.next(jeu);
int score = 0;
{
if (bouton.getLabel().equals("Brian Molko"))
score += 1;
else
score += 0;
if (bouton.getLabel().equals("Un chanteur"))
score += 1;
else
score += 0;
}
}
public static void main(String[] args) {
Frame f = new Jeu4();
}
} |
Partager