|
package quizzone;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Myframe extends JFrame {
private Jdb db;
private static int indx = 1, numrispesatte = 0;
private static String rispesatta = "",n ="";
super("Il Quizzone");
n = nome;
this. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
db = new Jdb();
conferma.addActionListener(
if (indx == 10) {
if (numrispesatte < 6) {
JOptionPane. showMessageDialog(null, numrispesatte + "/10 risposte giuste,devi studiare! ", "msg", JOptionPane. INFORMATION_MESSAGE);
} else if (numrispesatte > 5 && numrispesatte < 9) {
JOptionPane. showMessageDialog(null, numrispesatte + "/10 risposte giuste, punteggio buono! ", "msg", JOptionPane. INFORMATION_MESSAGE);
} else if (numrispesatte > 8) {
JOptionPane. showMessageDialog(null, numrispesatte + "/10 risposte giuste, bravo ottimo punteggio ", "msg", JOptionPane. INFORMATION_MESSAGE);
}
db.insert(n, numrispesatte);
new Record();
setVisible(false);
} else {
if (f != null) {
if (rispesatta.equals(f.getActionCommand())) {
numrispesatte++;
}
indx++;
initx();
} else {
}
}
}
});
p. setBackground(Color. blue);
for (int i = 0; i < 4; i++) {
bg.add(risp[i]);
risp [i ]. setBackground(new Color(0,64,128 ));
risp [i ]. setForeground(Color. ORANGE);
risp [i ]. setFont(new Font("Arial", Font. BOLD, 16 ));
p.add(risp[i]);
}
pc. setBackground(Color. blue);
pc.add(conferma);
pt. setBackground(Color. blue);
txt. setForeground(Color. red);
txt. setFont(new Font("Arial", Font. BOLD, 20 ));
pt.add(txt);
this.getContentPane().add(pt, "North");
this.getContentPane().add(p, "Center");
this.getContentPane().add(pc, "South");
setResizable(false);
setVisible(true);
setBounds(200, 200,770,250);
initx();
}
public void initx() {
String[] opt = db. estrai(indx );
txt.setText(" " + opt[0]);
for (int i = 0; i < 4; i++) {
risp[i].setText(opt[i + 1]);
risp[i].setActionCommand(opt[i + 1]);
}
rispesatta = opt[5];
}
}//fine class
|
|