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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
public class Test extends JFrame implements ActionListener{ {
private JPanel pan = new JPanel();
private PanneauQuestionPhysique panneauQuestionPhysique1 = new PanneauQuestionPhysique();
protected static int hasard = (int)(Math.random()*14);
protected static Color vert = new Color(34,139,34);
protected static Color lightcyan = new Color(176,196,222);
protected static Color skyblue = new Color(0,191,255);
protected static Color turquoise = new Color(0,206,209);
protected static Color olive = new Color(202,255,112);
protected static boutonRejouer jButton1 = new boutonRejouer();
protected static b0 jButton2 = new b0(lightcyan);
protected static b12 jButton8 = new b12(skyblue);
protected static b16 jButton10 = new b16(Color.CYAN);
protected static b18 jButton11 = new b18(turquoise);
protected static b20 jButton12 = new b20(olive);
protected static b20 jButton13 = new b20(lightcyan);
private PanneauPlateau panneauPlateau = new PanneauPlateau();
protected static PanneauDe panDe = new PanneauDe();
private PanneauTest Panneau = new PanneauTest();
private void jbInit() throws Exception {
this.setSize(new Dimension(1000, 600));
Panneau.setLayout(null);
this.setContentPane(Panneau);
Panneau.add(panneauPlateau, null);
this.getContentPane().add(jButton1, null);
this.getContentPane().add(jButton2, null);
this.getContentPane().add(jButton8, null);
this.getContentPane().add(jButton10, null);
this.getContentPane().add(jButton12, null);
this.getContentPane().add(jButton13, null);
jButton1.setBounds(new Rectangle(880,80,100,20));
jButton2.setBounds(new Rectangle(880,105,100,20));
jButton8.setBounds(new Rectangle(880,255,100,20));
jButton10.setBounds(new Rectangle(880,305,100,20));
jButton11.setBounds(new Rectangle(880,330,100,20));
jButton12.setBounds(new Rectangle(880,355,100,20));
jButton13.setBounds(new Rectangle(880,380,100,20));
jButton1.setEnabled(false);
jButton2.setEnabled(false);
jButton8.setEnabled(false);
jButton10.setEnabled(false);
jButton11.setEnabled(false);
jButton12.setEnabled(false);
jButton13.setEnabled(false);
this.getContentPane().add(panDe, null);
this.setLocationRelativeTo(null);
//panDe.setBounds(new Rectangle(0,905,110,125));
panneauPlateau.setBounds(new Rectangle(05, 05, 830, 350));
}
public Test(){
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
this.setVisible(true);
this.setTitle("ANDROID");
this.setLocationRelativeTo(null);
//this.setResizable(false);
}
private class PanneauQuestionPhysique extends JPanel{
protected static int hasard = (int)(Math.random()*14);
private String question="";
private String A="";
private String B="";
private String C="";
private String D="";
private String bonnerep="";
private JLabel labelQuestion = new JLabel(question);
private JPanel panneauQP = new JPanel();
private JButton c1 = new JButton(A);
private JButton c2 = new JButton(B);
private JButton c3 = new JButton(C);
private JButton c4 = new JButton(D);
private JLabel labelreponse = new JLabel("Choisissez une reponse.");
private JLabel labelOK = new JLabel("Bravo !");
private JLabel labelF = new JLabel ("<html>Dommage... <br/>La bonne reponse etait "+bonnerep+".<html/>");
public void PanneauQuestionPhysique() {
int hasard = (int)this.chiffreHasard();
String[] questions={"};
String[] A={"les questions sont ici"};
String[] B={"les questions sont ici"};
String[] C={"les questions sont ici"};
String[] D={"les questions sont ici"};
String[] bonnesreps={""};
question = questions[hasard];
* c1 = A[hasard];
* c2 = B[hasard];
* c3 = C[hasard];
* c4 = D[hasard];
* c1.setText(A);
* c2.setText(B);
* c3.setText(C);
* c4.setText(D);
labelF.setText("<html>Dommage... <br/>La bonne reponse etait "+bonnerep+".<html/>");
this.setLayout(new BorderLayout());
this.add(labelQuestion, BorderLayout.NORTH);
this.add(panneauQP, BorderLayout.CENTER);
panneauQP.setLayout(null);
panneauQP.add(c1, null);
panneauQP.add(c2, null);
panneauQP.add(c3, null);
panneauQP.add(c4, null);
panneauQP.add(labelreponse, null);
c1.setBounds(new Rectangle(400, 400, 100, 25));
c2.setBounds(new Rectangle(400, 400, 100, 25));
c3.setBounds(new Rectangle(400, 450, 100, 25));
c4.setBounds(new Rectangle(400, 450, 100, 25));
labelreponse.setBounds(new Rectangle(5, 200, 100, 25));
* c1.addActionListener(new StateListener());
* c2.addActionListener(new StateListener());
* c3.addActionListener(new StateListener());
* c4.addActionListener(new StateListener());
c4.setBackground(PanneauPlateau.skyblue);
labelQuestion.setForeground(Color.BLUE);
}
public int chiffreHasard(){
if (hasard>13){
hasard=0;
}else{
hasard=hasard+1;
}
return hasard;
}
public void paintComponent(Graphics g){
try {
Image img = ImageIO.read(this.getClass().getResourceAsStream("Fcour.jpg"));
g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(),this);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
} |
Partager