CODE
CODE
CODE
Login.java
package quizapllication;
import java.awt.Color;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
Login() {
getContentPane().setBackground(Color.WHITE);
setLayout(null);
ImageIcon i1 = new
ImageIcon(ClassLoader.getSystemResource("icons/Login.jpeg"));
JLabel image = new JLabel(i1);
image.setBounds(0, 0, 600, 500);
add(image);
setSize(1200, 500);
setLocation(340, 200);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == Rules) {
String name = tfname.getText();
setVisible(false);
new Rules(name);
Rules.java
package quizapllication;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
String name;
JButton Start , Back;
setSize(1080, 650);
setLocation(350, 150);
setVisible(true);
}
} else {
setVisible(false);
new Login();
}
}
}
Quiz.java
package quizapllication;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
String name;
Quiz(String name) {
this.name = name;
setBounds(50, 0, 1440, 850);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
ImageIcon i1 = new
ImageIcon(ClassLoader.getSystemResource("icons/quiz.jpg"));
JLabel image = new JLabel(i1);
image.setBounds(0, 0, 1440, 392);
add(image);
answers[0][1] = "JDB";
answers[1][1] = "int";
answers[2][1] = "java.util package";
answers[3][1] = "Marker Interface";
answers[4][1] = "Heap memory";
answers[5][1] = "Remote interface";
answers[6][1] = "import";
answers[7][1] = "Java Archive";
answers[8][1] = "java.lang.StringBuilder";
answers[9][1] = "Bytecode is executed by JVM";
start(count);
setVisible(true);
}
ans_given = 1;
if (groupoptions.getSelection() == null) {
useranswers[count][0] = "";
} else {
useranswers[count][0] =
groupoptions.getSelection().getActionCommand();
}
if (count == 8) {
next.setEnabled(false);
submit.setEnabled(true);
}
count++;
start(count);
} else if (ae.getSource() == lifeline) {
if (count == 2 || count == 4 || count == 6 || count == 8 || count == 9) {
opt2.setEnabled(false);
opt3.setEnabled(false);
} else {
opt1.setEnabled(false);
opt4.setEnabled(false);
}
lifeline.setEnabled(false);
} else if (ae.getSource() == submit) {
ans_given = 1;
if (groupoptions.getSelection() == null) {
useranswers[count][0] = "";
} else {
useranswers[count][0] =
groupoptions.getSelection().getActionCommand();
}
if (timer > 0) {
g.drawString(time, 1100, 500);
} else {
g.drawString("Times up!!", 1100, 500);
}
timer--; // 14
try {
Thread.sleep(1000);
repaint();
} catch (Exception e) {
e.printStackTrace();
}
if (ans_given == 1) {
ans_given = 0;
timer = 15;
} else if (timer < 0) {
timer = 15;
opt1.setEnabled(true);
opt2.setEnabled(true);
opt3.setEnabled(true);
opt4.setEnabled(true);
if (count == 8) {
next.setEnabled(false);
submit.setEnabled(true);
}
if (count == 9) { // submit button
if (groupoptions.getSelection() == null) {
useranswers[count][0] = "";
} else {
useranswers[count][0] =
groupoptions.getSelection().getActionCommand();
}
opt2.setText(questions[count][2]);
opt2.setActionCommand(questions[count][2]);
opt3.setText(questions[count][3]);
opt3.setActionCommand(questions[count][3]);
opt4.setText(questions[count][4]);
opt4.setActionCommand(questions[count][4]);
groupoptions.clearSelection();
}
Score.java
package quizapllication;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
ImageIcon i1 = new
ImageIcon(ClassLoader.getSystemResource("icons/score.png"));
Image i2 = i1.getImage().getScaledInstance(300, 250,
Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel image = new JLabel(i3);
image.setBounds(0, 200, 300, 250);
add(image);
JLabel heading = new JLabel("Thankyou " + name + " for playing Simple
Minds");
heading.setBounds(45, 30, 700, 30);
heading.setFont(new Font("Tahoma", Font.PLAIN, 26));
add(heading);
setVisible(true);
}