update
This commit is contained in:
@@ -1,17 +1,76 @@
|
||||
package Vue;
|
||||
|
||||
import javax.swing.*;
|
||||
import Modele.Question;
|
||||
import Modele.Questionnaire;
|
||||
import Modele.ChoixUtilisateur;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Classe pour l'affichage des questions
|
||||
*/
|
||||
public class AffichageQuestion {
|
||||
public class AffichageQuestion extends JPanel {
|
||||
|
||||
/**
|
||||
* Mode solution activé ou non (false si mode questionnaire, true si mode solution)
|
||||
*/
|
||||
private boolean modeSolution;
|
||||
|
||||
private JRadioButton[] boutonsChoix;
|
||||
|
||||
/**
|
||||
* Constructeur de la classe AffichageQuestion
|
||||
*/
|
||||
public AffichageQuestion() {
|
||||
this.modeSolution = false;
|
||||
this.modeSolution = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Copylot crap
|
||||
package Vue;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import Modele.Question;
|
||||
import Modele.ChoixUtilisateur;
|
||||
|
||||
public class AffichageQuestion extends JPanel {
|
||||
private boolean modeSolution;
|
||||
private ButtonGroup group;
|
||||
private JRadioButton[] boutons;
|
||||
private JLabel labelQuestion;
|
||||
|
||||
public AffichageQuestion(Question question, int indexQuestion, ChoixUtilisateur choixUtilisateur, boolean modeSolution) {
|
||||
this.modeSolution = modeSolution;
|
||||
setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
labelQuestion = new JLabel(question.makeNewQuestion());
|
||||
gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 2;
|
||||
add(labelQuestion, gbc);
|
||||
|
||||
String[] propositions = question.getPropositions();
|
||||
boutons = new JRadioButton[propositions.length];
|
||||
group = new ButtonGroup();
|
||||
|
||||
for (int i = 0; i < propositions.length; i++) {
|
||||
boutons[i] = new JRadioButton(propositions[i]);
|
||||
boutons[i].setEnabled(!modeSolution);
|
||||
if (choixUtilisateur.getChoix(indexQuestion) == i) {
|
||||
boutons[i].setSelected(true);
|
||||
}
|
||||
if (modeSolution) {
|
||||
if (i == question.getCorrectIndex()) {
|
||||
boutons[i].setForeground(Color.GREEN);
|
||||
} else if (choixUtilisateur.getChoix(indexQuestion) == i) {
|
||||
boutons[i].setForeground(Color.RED);
|
||||
}
|
||||
}
|
||||
group.add(boutons[i]);
|
||||
gbc.gridy = i + 1; gbc.gridwidth = 2;
|
||||
add(boutons[i], gbc);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
Reference in New Issue
Block a user