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
| else if (e.getOperation() == Operation.ADD) {
final List<Question> questions = model.getQuestions(e
.getChapterIndex());
final ArrayList<JPanel> panels = new ArrayList<JPanel>();
for (Question q : questions) {
final JPanel panel = new JPanel(new GridLayout(0, 3, 5,
5));
final String quest = q.getTitle();
final int level = q.getLevel();
final JTextArea text = new JTextArea(" "+q.getTitle()+" niv : "+q.getLevel());
text.setLineWrap(true);
text.setWrapStyleWord(true);
text.setBorder(border);
text.setBackground(null);
text.setEditable(false);
final JTextArea textArea = new JTextArea(3, 20);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setBorder(border);
final JButton button = new JButton("Valider");
panel.add(text);
panel.add(textArea);
panel.add(button);
questionsPanel.add(panel);
panels.add(panel);
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(quest);
System.out.println(chapterName);
System.out.println(textArea.getText());
model.insertRep(indexchap,quest, textArea.getText());
if ((textArea.getText().equals("oui")) && (level==1))
{
System.out.println("je dois supprimer les question de niveau supérieur");
}
}
});
}
questionPanels.put(chapterName, panels);
} |
Partager