diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..a1c524a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,26 @@
+
+ 4.0.0
+ com.ayushmaanbhav
+ customquiz
+ 0.0.1-SNAPSHOT
+ CustomQuiz
+ Quiz application for quiz or public or KBC like events.
+ http://github.com/ayushmaanbhav/customquiz
+
+
+ uk.co.caprica
+ vlcj
+ 3.0.1
+
+
+ net.java.dev.jna
+ jna
+ 3.5.2
+
+
+ net.java.dev.jna
+ platform
+ 3.5.2
+
+
+
\ No newline at end of file
diff --git a/src/main/java/BServer.java b/src/main/java/BServer.java
new file mode 100644
index 0000000..34a10d8
--- /dev/null
+++ b/src/main/java/BServer.java
@@ -0,0 +1,44 @@
+import java.io.*;
+import java.net.*;
+
+public class BServer extends Thread {
+ protected DatagramSocket socket = null;
+ private long SECONDS;
+ public boolean started;
+ public int port;
+ public String iip;
+
+ public BServer(String ip, int p) {
+ try {
+ iip = ip;
+ port = p;
+ socket = new DatagramSocket(4445);
+ SECONDS = 5000;
+ started = true;
+ } catch (Exception e) {
+ }
+ }
+
+ public void run() {
+ while (started) {
+ try {
+ String dString = iip + ":" + port;
+ byte[] buf = new byte[128];
+ buf = dString.getBytes();
+ InetAddress group = InetAddress.getByName("230.0.0.1");
+ DatagramPacket packet = new DatagramPacket(buf, buf.length,
+ group, 4447);
+ socket.send(packet);
+ System.out.println("sent");
+ try {
+ sleep(SECONDS);
+ } catch (InterruptedException e) {
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return;
+ }
+ }
+ socket.close();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/BasicWindowMonitor.java b/src/main/java/BasicWindowMonitor.java
new file mode 100644
index 0000000..c6e590c
--- /dev/null
+++ b/src/main/java/BasicWindowMonitor.java
@@ -0,0 +1,11 @@
+import java.awt.event.*;
+import java.awt.Window;
+
+public class BasicWindowMonitor extends WindowAdapter {
+ public void windowClosing(WindowEvent e) {
+ Window w = e.getWindow();
+ w.setVisible(false);
+ w.dispose();
+ System.exit(0);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/CustomQuiz.java b/src/main/java/CustomQuiz.java
new file mode 100644
index 0000000..f10bf2a
--- /dev/null
+++ b/src/main/java/CustomQuiz.java
@@ -0,0 +1,1351 @@
+import java.io.*;
+
+import javax.swing.*;
+import javax.swing.text.*;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.border.*;
+import javax.swing.plaf.basic.BasicInternalFrameUI;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import com.sun.jna.Native;
+import com.sun.jna.NativeLibrary;
+
+import java.awt.image.BufferedImage;
+import java.net.URISyntaxException;
+
+import uk.co.caprica.vlcj.binding.LibVlc;
+import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
+import uk.co.caprica.vlcj.player.MediaPlayerFactory;
+import uk.co.caprica.vlcj.runtime.RuntimeUtil;
+
+class CustomQuiz implements ActionListener {
+ JFrame frame;
+ JTextPane textPane;
+ JButton opt[], next, prev, cat[], answer, options, pass, lf1, lf2;
+ JScrollPane qq;
+ Answer an;
+ String subQues[] = null;
+ JDialog jd;
+ JInternalFrame internalFrame, internalFrame2, internalFrame3,
+ internalFrame4, internalFrame5;
+ Ques q;
+ Thread t = null, t2 = null, t3 = null, t4 = null;
+ Color color, yellow = Color.yellow.brighter().brighter();
+ MenuActListener mal;
+ int bbb = 0;
+ Sound sound;
+ int k = 0, l = 0;
+ boolean showpic, showtxt;
+ KeyEventDispatcher ked, ked2;
+ StopWatch sw;
+ int ques;
+ BufferedImage image;
+ Ques bon = null;
+ float ii;
+ MediaPlayerFactory factory;
+ CustomQuiz var;
+ Timer alphaChanger;
+ EmbeddedMediaPlayerComponent mediaPlayer;
+
+ @SuppressWarnings("deprecation")
+ public void actionPerformed(ActionEvent ae) {
+ final String ac = ae.getActionCommand();
+ if ((k == 2) && (ac.equals("Pass Question"))) {
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ sw.stopBtn.doClick();
+ sw.reset(Integer.parseInt(rounds[Ques.category].passingTime));
+ t3 = new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ } catch (Exception cf) {
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ sw.startBtn.doClick();
+ }
+ });
+ }
+ };
+ t3.start();
+ } else if ((k == 2)
+ && (ac.equals("10") || ac.equals("11") || ac.equals("12") || ac
+ .equals("13"))) {
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ opt[Integer.parseInt(ac) - 10].setBackground(yellow);
+ opt[Integer.parseInt(ac) - 10].updateUI();
+ } else if (ac.equals("Next Ques")) {
+ k = 0;
+ l = 0;
+ try {
+ t.stop();
+ t3.stop();
+ t4.stop();
+ } catch (Exception mm) {
+ }
+ t = new Thread() {
+ public void run() {
+ try {
+ t2.stop();
+ } catch (Exception mm) {
+ }
+ try {
+ /*
+ * if(bbb==1) { q=bon; } else
+ */
+ {
+ q = Ques.readNextQues();
+ }
+ mediaPlayer.getMediaPlayer().playMedia(background);
+ // label.setIcon(new ImageIcon((new
+ // ImageIcon("default.jpg").getImage()).getScaledInstance(label.getWidth(),label.getHeight(),Image.SCALE_SMOOTH)));
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(frame,
+ "Question Not Found.", "Error:",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings({ "restriction", "serial" })
+ public void run() {
+ if (q.ques == null) {
+ JOptionPane.showMessageDialog(frame,
+ "Question Not Found.", "Error:",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ if (rounds[Ques.category].type.equals("category"))// q.sub!=null
+ // &&
+ // subQues!=null && bbb==0)
+ {
+ internalFrame2.setTitle("Question:");
+ internalFrame2.updateUI();
+ textPane.setText(" ");
+ textPane.updateUI();
+ opt[0].setText(" ");
+ opt[1].setText(" ");
+ opt[2].setText(" ");
+ opt[3].setText(" ");
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ jd = new JDialog() {
+ @Override
+ public void setVisible(boolean b) {
+ try {
+ if (b == false)
+ manager.removeKeyEventDispatcher(ked2);
+ else
+ manager.addKeyEventDispatcher(ked2);
+ } catch (Exception e) {
+ }
+ super.setVisible(b);
+ }
+ };
+ ked2 = new KeyEventDispatcher() {
+ public boolean dispatchKeyEvent(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ jd.setVisible(false);
+ }
+ return false;
+ }
+ };
+ jd.setUndecorated(true);
+ JPanel contentPane = new JPanel() {
+ @Override
+ protected void paintComponent(
+ Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(
+ RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0,
+ 0, getBackground().brighter()
+ .brighter(), 0,
+ getHeight(), getBackground()
+ .darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(),
+ getHeight());
+ super.paintComponent(grphcs);
+ }
+ };
+ contentPane.setOpaque(false);
+ jd.setContentPane(contentPane);
+ contentPane.setLayout(new GridLayout((int) Math
+ .ceil(Math.sqrt(subQues.length)),
+ (int) Math.floor(Math
+ .sqrt(subQues.length))));
+ JButton jj[] = new JButton[subQues.length];
+ for (int i = 0; i < jj.length; i++) {
+ jj[i] = new JButton(
+ subQues[i].split("=")[0]);
+ jj[i].setPreferredSize(new Dimension(360,
+ 203));
+ jj[i].addActionListener(var);
+ jj[i].setActionCommand("cat:" + i);
+ jj[i].setFont(new Font(
+ "Lucida Sans Unicode", Font.BOLD,
+ 25));
+ jj[i].setEnabled(Integer
+ .parseInt(subQues[i].split("=")[1]
+ .split(":")[0]) > 0 ? true
+ : false);
+ contentPane.add(jj[i]);
+ }
+ contentPane.setBorder(BorderFactory
+ .createLineBorder(Color.black, 1));
+ jd.pack();
+ jd.setAlwaysOnTop(true);
+ jd.setLocationRelativeTo(frame);
+ com.sun.awt.AWTUtilities.setWindowOpacity(jd,
+ Float.valueOf(0));
+ jd.setVisible(true);
+ ii = 0;
+ alphaChanger = new Timer(70,
+ new ActionListener() {
+
+ private float incrementer = .10f;
+
+ public void actionPerformed(
+ ActionEvent e) {
+ ii = ii + incrementer;
+ com.sun.awt.AWTUtilities
+ .setWindowOpacity(
+ jd,
+ Float.valueOf(ii));
+ if (ii > ((float) 0.9)) {
+ alphaChanger.stop();
+ com.sun.awt.AWTUtilities.setWindowOpacity(
+ jd,
+ Float.valueOf(1));
+ }
+ }
+ });
+ alphaChanger.start();
+ } else {
+ bbb = 0;
+ internalFrame2.setTitle("Question: Level-"
+ + Ques.qno);
+ internalFrame2.updateUI();
+ textPane.setText(q.ques);
+ textPane.updateUI();
+ opt[0].setText(" ");
+ opt[1].setText(" ");
+ opt[2].setText(" ");
+ opt[3].setText(" ");
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ if (q.img != null)
+ // label.setIcon(new
+ // ImageIcon((q.img.getImage()).getScaledInstance(label.getWidth(),label.getHeight(),Image.SCALE_SMOOTH)));
+ mediaPlayer
+ .getMediaPlayer()
+ .playMedia(
+ new File(
+ rounds[Ques.category].folder,
+ q.img)
+ .getAbsolutePath());
+ if (rounds[Ques.category].type.equals("normal")) {
+ sw.stopBtn.doClick();
+ sw.reset(Integer
+ .parseInt(rounds[Ques.category].time));
+ }
+
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].autostart)
+ && rounds[Ques.category].autostartAfter
+ .equals("question"))
+ sw.startBtn.doClick();
+
+ k = 1;
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].optionsAutoload)) {
+ options.doClick();
+ }
+ }
+ }
+ });
+ }
+ };
+ t.start();
+ } else if (ac.equals("Prev Ques")) {
+ k = 0;
+ l = 0;
+ try {
+ t.stop();
+ t3.stop();
+ t4.stop();
+ } catch (Exception mm) {
+ }
+ t = new Thread() {
+ public void run() {
+ try {
+ t2.stop();
+ } catch (Exception mm) {
+ }
+ try {
+ q = Ques.readPreviousQues();
+ mediaPlayer.getMediaPlayer().playMedia(background);
+ // label.setIcon(new ImageIcon((new
+ // ImageIcon("default.jpg").getImage()).getScaledInstance(label.getWidth(),label.getHeight(),Image.SCALE_SMOOTH)));
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(frame,
+ "Question Not Found.", "Error:",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ @SuppressWarnings({ "serial", "restriction" })
+ public void run() {
+ if (q.ques == null) {
+ JOptionPane.showMessageDialog(frame,
+ "Question Not Found.", "Error:",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ if (rounds[Ques.category].type.equals("category")) {
+ internalFrame2.setTitle("Question:");
+ internalFrame2.updateUI();
+ textPane.setText(" ");
+ textPane.updateUI();
+ opt[0].setText(" ");
+ opt[1].setText(" ");
+ opt[2].setText(" ");
+ opt[3].setText(" ");
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ jd = new JDialog() {
+ @Override
+ public void setVisible(boolean b) {
+ try {
+ if (b == false)
+ manager.removeKeyEventDispatcher(ked2);
+ else
+ manager.addKeyEventDispatcher(ked2);
+ } catch (Exception e) {
+ }
+ super.setVisible(b);
+ }
+ };
+ ked2 = new KeyEventDispatcher() {
+ public boolean dispatchKeyEvent(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ jd.setVisible(false);
+ }
+ return false;
+ }
+ };
+ jd.setUndecorated(true);
+ JPanel contentPane = new JPanel() {
+ @Override
+ protected void paintComponent(
+ Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(
+ RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0,
+ 0, getBackground().brighter()
+ .brighter(), 0,
+ getHeight(), getBackground()
+ .darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(),
+ getHeight());
+ super.paintComponent(grphcs);
+ }
+ };
+ contentPane.setOpaque(false);
+ jd.setContentPane(contentPane);
+ contentPane.setLayout(new GridLayout((int) Math
+ .ceil(Math.sqrt(subQues.length)),
+ (int) Math.floor(Math
+ .sqrt(subQues.length))));
+ JButton jj[] = new JButton[subQues.length];
+ for (int i = 0; i < jj.length; i++) {
+ jj[i] = new JButton(
+ subQues[i].split("=")[0]);
+ jj[i].setPreferredSize(new Dimension(360,
+ 203));
+ jj[i].addActionListener(var);
+ jj[i].setActionCommand("cat:" + i);
+ jj[i].setFont(new Font(
+ "Lucida Sans Unicode", Font.BOLD,
+ 25));
+ jj[i].setEnabled(Integer
+ .parseInt(subQues[i].split("=")[1]
+ .split(":")[0]) > 0 ? true
+ : false);
+ contentPane.add(jj[i]);
+ }
+ contentPane.setBorder(BorderFactory
+ .createLineBorder(Color.black, 1));
+ jd.pack();
+ jd.setAlwaysOnTop(true);
+ jd.setLocationRelativeTo(frame);
+ com.sun.awt.AWTUtilities.setWindowOpacity(jd,
+ Float.valueOf(0));
+ jd.setVisible(true);
+ ii = 0;
+ alphaChanger = new Timer(70,
+ new ActionListener() {
+
+ private float incrementer = .10f;
+
+ public void actionPerformed(
+ ActionEvent e) {
+ ii = ii + incrementer;
+ com.sun.awt.AWTUtilities
+ .setWindowOpacity(
+ jd,
+ Float.valueOf(ii));
+ if (ii > ((float) 0.9)) {
+ alphaChanger.stop();
+ com.sun.awt.AWTUtilities.setWindowOpacity(
+ jd,
+ Float.valueOf(1));
+ }
+ }
+ });
+ alphaChanger.start();
+ } else {
+ internalFrame2.setTitle("Question: Level-"
+ + Ques.qno);
+ internalFrame2.updateUI();
+ textPane.setText(q.ques);
+ textPane.updateUI();
+ opt[0].setText(" ");
+ opt[1].setText(" ");
+ opt[2].setText(" ");
+ opt[3].setText(" ");
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ if (q.img != null)
+ // label.setIcon(new
+ // ImageIcon((q.img.getImage()).getScaledInstance(label.getWidth(),label.getHeight(),Image.SCALE_SMOOTH)));
+ mediaPlayer
+ .getMediaPlayer()
+ .playMedia(
+ new File(
+ rounds[Ques.category].folder,
+ q.img)
+ .getAbsolutePath());
+ if (rounds[Ques.category].type.equals("normal")) {
+ sw.stopBtn.doClick();
+ sw.reset(Integer
+ .parseInt(rounds[Ques.category].time));
+ }
+ k = 1;
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].autostart)
+ && rounds[Ques.category].autostartAfter
+ .equals("question"))
+ sw.startBtn.doClick();
+
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].optionsAutoload)) {
+ options.doClick();
+ }
+ }
+ }
+ });
+ }
+ };
+ t.start();
+ } else if ((k == 1) && ac.equals("Show Options")) {
+ t4 = new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(500);
+ } catch (Exception cf) {
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].setText(q.opta);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ textPane.updateUI();
+ }
+ });
+ // try{
+ // Thread.sleep(100);
+ // }catch(Exception cf){}
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ opt[1].setText(q.optb);
+ opt[1].updateUI();
+ }
+ });
+ // try{
+ // Thread.sleep(100);
+ // }catch(Exception cf){}
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ opt[2].setText(q.optc);
+ opt[2].updateUI();
+ }
+ });
+ // try{
+ // Thread.sleep(100);
+ // }catch(Exception cf){}
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ opt[3].setText(q.optd);
+ opt[3].updateUI();
+ }
+ });
+ k = 2;
+ try {
+ Thread.sleep(200);
+ } catch (Exception cf) {
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].autostart)
+ && rounds[Ques.category].autostartAfter
+ .equals("options"))
+ sw.startBtn.doClick();
+ }
+ });
+ }
+ };
+ t4.start();
+ } else if ((k == 2) && ac.equals("Show Answer")) {
+ if (!rounds[Ques.category].type.equals("rapidfire"))
+ sw.stopBtn.doClick();
+ /*
+ * if(Ques.category==1) { Thread t5=new Thread(){ public void run()
+ * { try{ an=Ques.readAnswer(); }catch(Exception e) {
+ * JOptionPane.showMessageDialog
+ * (frame,"Answer Not Found.","Error:",JOptionPane
+ * .INFORMATION_MESSAGE); return; } SwingUtilities.invokeLater(new
+ * Runnable(){ public void run() {
+ * textPane.setText(an.ans+"\n"+an.des); textPane.updateUI(); } });
+ * } }; t5.start(); } else
+ */
+ try {
+ if (q.imgans != null)
+ mediaPlayer.getMediaPlayer().playMedia(
+ new File(rounds[Ques.category].folder, q.imgans)
+ .getAbsolutePath());
+ l = 0;
+ opt[Integer.parseInt(q.ans) - 1].setBackground(Color.green
+ .brighter().brighter());
+ opt[Integer.parseInt(q.ans) - 1].updateUI();
+ for (int i = 0; i < 4; i++) {
+ if ((opt[i].getBackground() == yellow)
+ && i != (Integer.parseInt(q.ans) - 1)) {
+ l++;
+ opt[i].setBackground((Color.red).brighter().brighter());
+ opt[i].updateUI();
+ sound = new Sound();
+ sound.newClip(wrongSound);
+ sound.run();
+ }
+ }
+ if (l == 0) {
+ sound = new Sound();
+ sound.newClip(correctSound);
+ sound.run();
+ }
+ } catch (Exception m) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ textPane.setText(q.ans);
+ textPane.updateUI();
+ }
+ });
+ }
+ } else if (isRounds(ac)) {
+ internalFrame2.setTitle("Question:");
+ internalFrame2.updateUI();
+ textPane.setText(" ");
+ textPane.updateUI();
+ opt[0].setText(" ");
+ opt[1].setText(" ");
+ opt[2].setText(" ");
+ opt[3].setText(" ");
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ JButton jj = (JButton) ae.getSource();
+ for (int i = 0; i < rounds.length; i++) {
+ cat[i].setBackground(color);
+ cat[i].updateUI();
+ }
+ lf1.setEnabled(true);
+ lf2.setEnabled(true);
+ jj.setBackground(color.darker());
+ jj.updateUI();
+ Ques.category = Integer.parseInt(ac);
+ try {
+ subQues = Ques.readCategories();
+ } catch (Exception n) {
+ subQues = null;
+ }
+ Ques.qno = 0;
+ } else if ((k == 2) && ac.equals("5050")) {
+ int g = Integer.parseInt(q.ans) - 1;
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ int h = 0, l = 4;
+ while (h < 2) {
+ int i = ((int) (Math.random() * 100)) % 4;
+ if (i != g && i != l) {
+ opt[i].setText(" ");
+ l = i;
+ h++;
+ }
+ }
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ lf1.setEnabled(false);
+ } else if ((k == 2) && ac.equals("paf")) {
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ sw.stopBtn.doClick();
+ lf2.setEnabled(false);
+ } else if (ac.startsWith("cat")) {
+ jd.setVisible(false);
+ new Thread() {
+ // boolean bonus = false;
+
+ public void run() {
+ /*
+ * if(Integer.parseInt(subQues[Integer.parseInt(ac.split(":")
+ * [1])].split("=")[1])>1) { bonus=true;
+ * mediaPlayer.getMediaPlayer().playMedia("bonus.mp4"); try{
+ * Thread.sleep(10000); }catch(Exception mm){}
+ * mediaPlayer.getMediaPlayer().playMedia("default.jpg"); }
+ */
+ String cc = subQues[Integer.parseInt(ac.split(":")[1])]
+ .split("=")[0];
+ Ques.qno = 0;
+ int lko = Integer.parseInt(subQues[Integer.parseInt(ac
+ .split(":")[1])].split("=")[1].split(":")[1]);
+ subQues[Integer.parseInt(ac.split(":")[1])] = subQues[Integer
+ .parseInt(ac.split(":")[1])].split("=")[0]
+ + "="
+ + (Integer
+ .parseInt(subQues[Integer.parseInt(ac
+ .split(":")[1])].split("=")[1]
+ .split(":")[0]) - 1)
+ + ":"
+ + (lko + 1);
+ // System.out.println(subQues[Integer.parseInt(ac.split(":")[1])]);
+ bon = null;
+ bbb = 0;
+ while (true) {
+ try {
+ q = Ques.readNextQues();
+ if (q.sub.equals(cc)) {
+ if (bbb == lko)
+ break;
+ bbb++;
+ }
+ } catch (Exception mm) {
+ break;
+ }
+ }
+ Ques.qno = 0;
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ if (q == null || q.ques == null) {
+ JOptionPane.showMessageDialog(frame,
+ "Question Not Found.", "Error:",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ {
+ internalFrame2.setTitle("Question:");
+ internalFrame2.updateUI();
+ textPane.setText(q.ques);
+ textPane.updateUI();
+ opt[0].setText(" ");
+ opt[1].setText(" ");
+ opt[2].setText(" ");
+ opt[3].setText(" ");
+ opt[0].setBackground(color);
+ opt[1].setBackground(color);
+ opt[2].setBackground(color);
+ opt[3].setBackground(color);
+ opt[0].updateUI();
+ opt[1].updateUI();
+ opt[2].updateUI();
+ opt[3].updateUI();
+ if (q.img != null)
+ // label.setIcon(new
+ // ImageIcon((q.img.getImage()).getScaledInstance(label.getWidth(),label.getHeight(),Image.SCALE_SMOOTH)));
+ mediaPlayer
+ .getMediaPlayer()
+ .playMedia(
+ new File(
+ rounds[Ques.category].folder,
+ q.img)
+ .getAbsolutePath());
+ sw.stopBtn.doClick();
+ sw.reset(Integer
+ .parseInt(rounds[Ques.category].time));
+ k = 1;
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].autostart)
+ && rounds[Ques.category].autostartAfter
+ .equals("question"))
+ sw.startBtn.doClick();
+
+ if (Boolean
+ .parseBoolean(rounds[Ques.category].optionsAutoload)) {
+ options.doClick();
+ }
+ }
+ }
+ });
+ }
+ }.start();
+ }
+ }
+
+ private boolean isRounds(String ac) {
+ try {
+ int aa = Integer.parseInt(ac);
+ if (aa >= 0 && aa < rounds.length)
+ return true;
+ return false;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ JButton makeButton(String name) {
+ JButton temp = new JButton(name);
+ return temp;
+ }
+
+ JButton makeButton(ImageIcon img) {
+ JButton temp = new JButton(img);
+ return temp;
+ }
+
+ JMenuBar makeMenu() {
+ JMenuBar jmb = new JMenuBar();
+ jmb.setBorder(new BevelBorder(BevelBorder.RAISED));
+ JMenu fileMenu = new JMenu("Quiz Menu");
+ JMenuItem optItem = new JMenuItem("Options");
+ optItem.addActionListener(mal);
+ fileMenu.add(optItem);
+ JMenuItem abtItem = new JMenuItem("About");
+ abtItem.addActionListener(mal);
+ fileMenu.add(abtItem);
+ JMenuItem exitItem = new JMenuItem("Exit");
+ exitItem.addActionListener(mal);
+ fileMenu.add(exitItem);
+ jmb.add(fileMenu);
+ return jmb;
+ }
+
+ @SuppressWarnings("serial")
+ JPanel getQuestionAndOptionsPanel() {
+ JPanel j3 = new JPanel(new GridBagLayout()) {
+ @Override
+ protected void paintComponent(Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0, 0, getBackground()
+ .brighter().brighter(), getWidth(), getHeight(),
+ getBackground().darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ super.paintComponent(grphcs);
+ }
+ };
+ j3.setOpaque(false);
+ // ques=new JTextArea(3,20);
+ // ques.setLineWrap(true);
+ // ques.setWrapStyleWord(true);
+ // ques.setFont(new Font("Lucida Sans Unicode",Font.BOLD,20));
+ textPane = new JTextPane();
+ textPane.setSize(120, 40);
+ StyledDocument doc = textPane.getStyledDocument();
+ SimpleAttributeSet center = new SimpleAttributeSet();
+ StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
+ doc.setParagraphAttributes(0, doc.getLength(), center, false);
+ textPane.setFont(new Font("Lucida Sans Unicode", Font.BOLD, 23));
+ textPane.setText("!! Welcome !!");
+ textPane.setEditable(false);
+ qq = new JScrollPane(textPane,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
+ @Override
+ protected void paintComponent(Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0, 0, getBackground()
+ .brighter().brighter(), 0, getHeight(), getBackground()
+ .darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ super.paintComponent(grphcs);
+ }
+ };
+ qq.setOpaque(false);
+ // ques.setEditable(true);
+ qq.setPreferredSize(textPane.getPreferredSize());
+ GridBagConstraints tgrid;
+ tgrid = new GridBagConstraints();
+ tgrid.insets = new Insets(5, 5, 0, 5);
+ tgrid.weightx = tgrid.weighty = 1.0;
+ tgrid.fill = GridBagConstraints.BOTH;
+ tgrid.gridx = 0;
+ tgrid.gridy = 0;
+ tgrid.gridwidth = 2;
+ tgrid.gridheight = 1;
+ j3.add(qq, tgrid);
+ tgrid.gridwidth = 1;
+ tgrid.weightx = 0.5;
+ opt[0] = makeButton("A:");
+ opt[0].setActionCommand("10");
+ opt[1] = makeButton("B:");
+ opt[1].setActionCommand("11");
+ opt[2] = makeButton("C:");
+ opt[2].setActionCommand("12");
+ opt[3] = makeButton("D:");
+ color = opt[3].getBackground();
+ opt[3].setActionCommand("13");
+ for (int i = 0; i < 4; i++) {
+ opt[i].addActionListener(this);
+ opt[i].setFont(new Font("Lucida Sans Unicode", Font.BOLD, 20));
+ }
+ tgrid.gridx = 0;
+ tgrid.gridy = 1;
+ j3.add(opt[0], tgrid);
+ tgrid.gridx = 1;
+ j3.add(opt[1], tgrid);
+ tgrid.gridx = 0;
+ tgrid.gridy = 2;
+ j3.add(opt[2], tgrid);
+ tgrid.gridx = 1;
+ j3.add(opt[3], tgrid);
+ return j3;
+ }
+
+ @SuppressWarnings("serial")
+ JPanel menu() {
+ JPanel jp = new JPanel(new GridBagLayout()) {
+ @Override
+ protected void paintComponent(Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0, 0, getBackground()
+ .brighter().brighter(), getWidth(), getHeight(),
+ getBackground().darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ super.paintComponent(grphcs);
+ }
+ };
+ jp.setOpaque(false);
+ GridBagConstraints tgrid;
+ tgrid = new GridBagConstraints();
+ tgrid.fill = GridBagConstraints.BOTH;
+ tgrid.gridx = 0;
+ tgrid.gridy = 0;
+ tgrid.gridwidth = 2;
+ cat = new JButton[rounds.length];
+
+ int i;
+ for (i = 0; i < rounds.length; i++) {
+ cat[i] = makeButton(rounds[i].name);
+ }
+
+ for (i = 0; i < rounds.length; i++) {
+ cat[i].addActionListener(this);
+ cat[i].setActionCommand("" + i);
+ cat[i].setFont(new Font(cat[i].getFont().getFontName(), Font.BOLD,
+ 15));
+ tgrid.gridy = i;
+ jp.add(cat[i], tgrid);
+ }
+ tgrid.anchor = GridBagConstraints.PAGE_END; // bottom of space
+ tgrid.insets = new Insets(20, 0, 0, 0);
+ prev = makeButton("Prev Ques");
+ prev.setFont(new Font(prev.getFont().getFontName(), Font.BOLD, 15));
+ next = makeButton("Next Ques");
+ next.setFont(new Font(next.getFont().getFontName(), Font.BOLD, 15));
+ tgrid.gridwidth = 1;
+ tgrid.gridy = i + 1;
+ jp.add(prev, tgrid);
+ prev.addActionListener(this);
+ tgrid.gridx = 1;
+ jp.add(next, tgrid);
+ next.addActionListener(this);
+ tgrid.gridx = 0;
+ tgrid.gridwidth = 2;
+ tgrid.gridy = i + 2;
+ options = makeButton("Show Options");
+ options.setFont(new Font(prev.getFont().getFontName(), Font.BOLD, 15));
+ jp.add(options, tgrid);
+ options.addActionListener(this);
+ tgrid.gridx = 0;
+ tgrid.gridwidth = 2;
+ tgrid.gridy = i + 3;
+ tgrid.insets = new Insets(10, 0, 0, 0);
+ answer = makeButton("Show Answer");
+ answer.setFont(new Font(prev.getFont().getFontName(), Font.BOLD, 15));
+ jp.add(answer, tgrid);
+ answer.addActionListener(this);
+ tgrid.gridx = 0;
+ tgrid.gridwidth = 2;
+ tgrid.gridy = i + 4;
+ pass = makeButton("Pass Question");
+ pass.setFont(new Font(prev.getFont().getFontName(), Font.BOLD, 15));
+ jp.add(pass, tgrid);
+ pass.addActionListener(this);
+ pass.setEnabled(true);
+ return jp;
+ }
+
+ void unmovable(JInternalFrame jif) {
+ BasicInternalFrameUI ui = (BasicInternalFrameUI) jif.getUI();
+ Component north = ui.getNorthPane();
+ MouseMotionListener[] actions = (MouseMotionListener[]) north
+ .getListeners(MouseMotionListener.class);
+ for (int i = 0; i < actions.length; i++)
+ north.removeMouseMotionListener(actions[i]);
+ }
+
+ @SuppressWarnings("serial")
+ JPanel lifelines() {
+ JPanel jp = new JPanel(new FlowLayout()) {
+ @Override
+ protected void paintComponent(Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0, 0, getBackground()
+ .brighter().brighter(), getWidth(), getHeight(),
+ getBackground().darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ super.paintComponent(grphcs);
+ }
+ };
+ jp.setOpaque(false);
+ lf1 = new JButton(new ImageIcon(
+ new File(resourcesLocation, "5050.gif").getAbsolutePath()));
+ lf2 = new JButton(new ImageIcon(
+ new File(resourcesLocation, "paf.gif").getAbsolutePath()));
+ lf1.setEnabled(false);
+ lf2.setEnabled(false);
+ jp.add(lf1);
+ jp.add(lf2);
+ lf1.setActionCommand("5050");
+ lf2.setActionCommand("paf");
+ lf1.addActionListener(this);
+ lf2.addActionListener(this);
+ return jp;
+ }
+
+ KeyboardFocusManager manager;
+
+ String quizName, quizFolder, quizOrganiser;
+ String splashscreenFile, splashscreenTimeout;
+ String framewidth, frameheight;
+ String lifelinesEnabled;
+ String background;
+ static File baseLocation, resourcesLocation, quizBase;
+ String startAnimationEnabled, startAnimationFile;
+ String soundsEnabled, correctSound, wrongSound;
+
+ class Round {
+ String name, type, file, folder;
+ String optionsAutoload;
+ String timerEnabled, time, passingTime, autostart, timeout,
+ autostartAfter;
+ String passingEnabled;
+ String categoryFile;
+ }
+
+ static Round rounds[];
+
+ void init() throws URISyntaxException, ParserConfigurationException,
+ SAXException, IOException {
+ Ques.category = -1;
+ Ques.qno = -1;
+ manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ var = this;
+ LookAndFeel.set();
+
+ File base = new File(CustomQuiz.class.getProtectionDomain()
+ .getCodeSource().getLocation().toURI()).getParentFile();
+ baseLocation = base;
+ resourcesLocation = new File(base, "resources");
+ System.out.println(base.getAbsolutePath() + "\n"
+ + new File(base, "lib").getAbsolutePath() + "\njdk version: "
+ + System.getProperty("sun.arch.data.model") + " bits.");
+ System.setProperty("jna.library.path",
+ new File(base, "lib").getAbsolutePath());
+ NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), // "C:/Program Files (x86)/VideoLAN/VLC");
+ new File(base, "VLC").getAbsolutePath());
+ Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
+
+ File confg = new File(base, "confg.xml");
+ System.out.println(confg.getAbsolutePath());
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(confg);
+ doc.getDocumentElement().normalize();
+ Element e = (Element) doc.getElementsByTagName("quiz").item(0);
+ quizName = e.getAttribute("name");
+ quizFolder = e.getAttribute("location");
+ quizOrganiser = e.getAttribute("organiser");
+ framewidth = e.getAttribute("framewidth");
+ frameheight = e.getAttribute("frameheight");
+
+ quizBase = new File(base, quizFolder);
+
+ e = (Element) doc.getElementsByTagName("splashscreen").item(0);
+ splashscreenFile = new File(quizBase, e.getAttribute("file"))
+ .getAbsolutePath();
+ System.out.println(splashscreenFile);
+ splashscreenTimeout = e.getAttribute("timeout");
+
+ e = (Element) doc.getElementsByTagName("background").item(0);
+ background = new File(quizBase, e.getAttribute("file"))
+ .getAbsolutePath();
+
+ e = (Element) doc.getElementsByTagName("startanimation").item(0);
+ startAnimationEnabled = e.getAttribute("enabled");
+ startAnimationFile = new File(quizBase, e.getAttribute("file"))
+ .getAbsolutePath();
+
+ e = (Element) doc.getElementsByTagName("sounds").item(0);
+ soundsEnabled = e.getAttribute("enabled");
+ correctSound = new File(resourcesLocation, e.getAttribute("correct"))
+ .getAbsolutePath();
+ wrongSound = new File(resourcesLocation, e.getAttribute("wrong"))
+ .getAbsolutePath();
+
+ NodeList nl = doc.getElementsByTagName("round");
+ rounds = new Round[nl.getLength()];
+ for (int i = 0; i < nl.getLength(); i++) {
+ e = (Element) nl.item(i);
+ rounds[i] = new Round();
+ // System.out.println(e.toString()+""+nl.getLength());
+ rounds[i].name = e.getAttribute("name");
+ rounds[i].type = e.getAttribute("type");
+ rounds[i].folder = new File(quizBase, e.getAttribute("folder"))
+ .getAbsolutePath();
+ File roundBase = new File(rounds[i].folder);
+ rounds[i].file = new File(roundBase, e.getAttribute("file"))
+ .getAbsolutePath();
+
+ Element e1 = (Element) e.getElementsByTagName("options").item(0);
+ rounds[i].optionsAutoload = e1.getAttribute("autoload");
+
+ e1 = (Element) e.getElementsByTagName("timer").item(0);
+ rounds[i].autostart = e1.getAttribute("autostart");
+ rounds[i].time = e1.getAttribute("time");
+ rounds[i].timerEnabled = e1.getAttribute("enabled");
+ rounds[i].passingTime = e1.getAttribute("passing-time");
+ rounds[i].timeout = e1.getAttribute("start-timeout");
+ rounds[i].autostartAfter = e1.getAttribute("autostart-after");
+
+ e1 = (Element) e.getElementsByTagName("passing").item(0);
+ rounds[i].passingEnabled = e1.getAttribute("enabled");
+ }
+
+ lifelinesEnabled = "false";
+ }
+
+ void main() {
+ try {
+ init();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(0);
+ }
+
+ new Splash(splashscreenFile, Integer.parseInt(splashscreenTimeout))
+ .start();
+
+ try {
+ Thread.sleep(2500);
+ } catch (Exception e) {
+ }
+
+ mal = new MenuActListener(this);
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @SuppressWarnings("serial")
+ public void run() {
+ frame = new JFrame(quizName + " - " + quizOrganiser
+ + ", Developed by Ayush Jain");
+ frame.addWindowListener(new BasicWindowMonitor());
+ frame.setUndecorated(true);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setContentPane(new JPanel() {
+ @Override
+ protected void paintComponent(Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(
+ RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0, 0,
+ getBackground().brighter().brighter(),
+ getWidth(), getHeight(), getBackground()
+ .darker().darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ super.paintComponent(grphcs);
+ }
+ });
+
+ opt = new JButton[4];
+
+ mediaPlayer = new EmbeddedMediaPlayerComponent();
+
+ frame.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent evt) {
+ mediaPlayer.release();
+ System.exit(0);
+ }
+ });
+
+ frame.setJMenuBar(makeMenu());
+
+ JPanel j4 = (JPanel) frame.getContentPane();
+ j4.setLayout(new GridBagLayout());
+ j4.setOpaque(false);
+
+ sw = new StopWatch();
+ sw.launchStopWatch();
+
+ GridBagConstraints mgrid = new GridBagConstraints();
+ mgrid.fill = GridBagConstraints.BOTH;
+
+ mgrid.gridx = 0;
+ mgrid.gridy = 0;
+ mgrid.gridwidth = 1;
+ mgrid.gridheight = 2;
+ internalFrame4 = new JInternalFrame("Categories", false,
+ false, false, false);
+ internalFrame4.setContentPane(menu());
+ internalFrame4.pack();
+ internalFrame4.setVisible(true);
+ unmovable(internalFrame4);
+ j4.add(internalFrame4, mgrid);
+
+ mgrid.gridx = 3;
+ mgrid.gridy = 0;
+ mgrid.gridwidth = 1;
+ mgrid.gridheight = 1;
+ internalFrame = new JInternalFrame("Timer", false, false,
+ false, false);
+ internalFrame.setSize(sw.getSize());
+ internalFrame.setContentPane(sw);
+ internalFrame.setVisible(true);
+ unmovable(internalFrame);
+ j4.add(internalFrame, mgrid);
+
+ mgrid.gridx = 1;
+ mgrid.gridy = 0;
+ mgrid.gridwidth = 2;
+ mgrid.gridheight = 2;
+ internalFrame3 = new JInternalFrame(quizName + " - "
+ + quizOrganiser + ", Developed by Ayush Jain",
+ false, false, false, false);
+
+ int width = Integer.parseInt(framewidth);
+ int height = Integer.parseInt(frameheight);
+
+ internalFrame3.setContentPane(mediaPlayer);
+ internalFrame3.setSize(width, height);
+ internalFrame3
+ .setPreferredSize(new Dimension(width, height));
+ // internalFrame3.pack();
+ internalFrame3.setVisible(true);
+ unmovable(internalFrame3);
+ j4.add(internalFrame3, mgrid);
+
+ mgrid.gridx = 0;
+ mgrid.gridy = 2;
+ mgrid.gridwidth = 4;
+ mgrid.gridheight = 1;
+ internalFrame2 = new JInternalFrame("Questions", false,
+ false, false, false);
+ internalFrame2.setContentPane(getQuestionAndOptionsPanel());
+ internalFrame2.pack();
+ internalFrame2.setVisible(true);
+ unmovable(internalFrame2);
+ j4.add(internalFrame2, mgrid);
+
+ mgrid.gridx = 3;
+ mgrid.gridy = 1;
+ mgrid.gridwidth = 1;
+ mgrid.gridheight = 1;
+ internalFrame5 = new JInternalFrame("Lifelines", false,
+ false, false, false);
+ internalFrame5.setContentPane(lifelines());
+ internalFrame5.pack();
+ if (Boolean.parseBoolean(lifelinesEnabled))
+ internalFrame5.setVisible(true);
+ unmovable(internalFrame5);
+ j4.add(internalFrame5, mgrid);
+
+ frame.pack();
+
+ Rectangle scrdim = GraphicsEnvironment
+ .getLocalGraphicsEnvironment()
+ .getMaximumWindowBounds();
+ frame.setSize((int) scrdim.getWidth(),
+ (int) scrdim.getHeight());
+ // jd2.setLocation((scrdim.width-dim.width),(scrdim.height-dim.height));
+
+ // Dimension
+ // scrdim=Toolkit.getDefaultToolkit().getScreenSize();
+ // Dimension dim=frame.getSize();
+ frame.setLocation(0, 0);
+ // frame.setLocation((scrdim.width-dim.width)/2,(scrdim.height-dim.height)/2);
+ // frame.setResizable(false);
+
+ ked = new KeyEventDispatcher() {
+ public boolean dispatchKeyEvent(KeyEvent e) {
+ /*
+ * if(e.getKeyCode()==KeyEvent.VK_1) {
+ * Ques.category2=0; if(Ques.category==3) {
+ * Ques.qno=0; sw.stopBtn.doClick();
+ * sw.resetBtn1.doClick(); } } else
+ * if(e.getKeyCode()==KeyEvent.VK_2) {
+ * Ques.category2=1; if(Ques.category==3) {
+ * Ques.qno=0; sw.stopBtn.doClick();
+ * sw.resetBtn1.doClick(); } } else
+ * if(e.getKeyCode()==KeyEvent.VK_3) {
+ * Ques.category2=2; if(Ques.category==3) {
+ * Ques.qno=0; sw.stopBtn.doClick();
+ * sw.resetBtn1.doClick(); } } else
+ * if(e.getKeyCode()==KeyEvent.VK_4) {
+ * Ques.category2=3; if(Ques.category==3) {
+ * Ques.qno=0; sw.stopBtn.doClick();
+ * sw.resetBtn1.doClick(); } } else
+ * if(e.getKeyCode()==KeyEvent.VK_5) {
+ * Ques.category2=4; if(Ques.category==3) {
+ * Ques.qno=0; sw.stopBtn.doClick();
+ * sw.resetBtn1.doClick(); } } else
+ * if(e.getKeyCode()==KeyEvent.VK_6) {
+ * Ques.category2=5; if(Ques.category==3) {
+ * Ques.qno=0; sw.stopBtn.doClick();
+ * sw.resetBtn1.doClick(); } } else
+ */if (e.getKeyCode() == KeyEvent.VK_A) {
+ sound = new Sound();
+ sound.newClip(correctSound);
+ sound.run();
+ } else if (e.getKeyCode() == KeyEvent.VK_S) {
+ sound = new Sound();
+ sound.newClip(wrongSound);
+ sound.run();
+ } else if (e.getKeyCode() == KeyEvent.VK_B) {
+ if (Boolean.parseBoolean(startAnimationEnabled)) {
+ mediaPlayer.getMediaPlayer().playMedia(
+ startAnimationFile);
+ }
+ }
+
+ return false;
+ }
+ };
+ manager.addKeyEventDispatcher(ked);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ frame.setVisible(true);
+ try {
+ internalFrame.setSelected(true);
+ internalFrame5.setSelected(true);
+ internalFrame2.setSelected(true);
+ internalFrame3.setSelected(true);
+ internalFrame4.setSelected(true);
+ } catch (Exception f) {
+ }
+ if (Boolean.parseBoolean(startAnimationEnabled)) {
+ mediaPlayer.getMediaPlayer().playMedia(startAnimationFile);
+ } else {
+ mediaPlayer.getMediaPlayer().playMedia(background);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/LookAndFeel.java b/src/main/java/LookAndFeel.java
new file mode 100644
index 0000000..fb1ba27
--- /dev/null
+++ b/src/main/java/LookAndFeel.java
@@ -0,0 +1,18 @@
+import javax.swing.UIManager.LookAndFeelInfo;
+import javax.swing.UIManager;
+
+class LookAndFeel {
+ public static void set() {
+ try {
+ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ UIManager.setLookAndFeel(info.getClassName()); // com.sun.java.swing.plaf.windows.WindowsLookAndFeel
+ break;
+ }
+ }
+ } catch (Exception e) {
+ // If Nimbus is not available, you can set the GUI to another look
+ // and feel.
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
new file mode 100644
index 0000000..a62fb82
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,6 @@
+public class Main {
+ public static void main(String args[]) {
+ CustomQuiz a = new CustomQuiz();
+ a.main();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/MenuActListener.java b/src/main/java/MenuActListener.java
new file mode 100644
index 0000000..b3f1253
--- /dev/null
+++ b/src/main/java/MenuActListener.java
@@ -0,0 +1,103 @@
+import javax.swing.*;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.event.ItemListener;
+import java.awt.event.ItemEvent;
+
+class MenuActListener implements ActionListener, ChangeListener, ItemListener {
+ JSlider slider;
+ JDialog jd = null;
+ int value = 25;
+ CustomQuiz k;
+
+ public MenuActListener(CustomQuiz k) {
+ this.k = k;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ String choice = e.getActionCommand();
+ if (choice == "Exit") {
+ System.exit(0);
+ } else if (choice == "Options") {
+ if (jd == null) {
+ int w = 250, h = 150;
+ jd = new JDialog(k.frame, "Options: Volume");
+ Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
+ int X = (screen.width / 2) - (w / 2);
+ int Y = (screen.height / 2) - (h / 2);
+ jd.setBounds(X, Y, w, h);
+ jd.setResizable(false);
+ JButton ok, cancel;
+
+ ok = new JButton("Ok");
+ ok.addActionListener(this);
+ cancel = new JButton("Cancel");
+ cancel.addActionListener(this);
+
+ slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 25);
+ slider.setDoubleBuffered(true);
+ slider.setMinorTickSpacing(2);
+ slider.setMajorTickSpacing(10);
+ slider.setPaintTicks(true);
+ slider.setPaintLabels(true);
+ slider.setLabelTable(slider.createStandardLabels(10));
+ slider.addChangeListener(this);
+
+ JCheckBox jc1 = new JCheckBox("Mute", false);
+ jc1.setDoubleBuffered(true);
+ jc1.addItemListener(this);
+ JCheckBox jc2 = new JCheckBox("Enable Sound", true);
+ jc2.setDoubleBuffered(true);
+ jc2.addItemListener(this);
+
+ JPanel as = new JPanel();
+ as.add(jc1, BorderLayout.SOUTH);
+ as.add(jc2);
+ as.add(slider);
+ as.add(ok);
+ as.add(cancel);
+
+ jd.add(as);
+
+ jd.setVisible(true);
+ } else if (jd.isVisible() == false) {
+ jd.setVisible(true);
+ }
+ } else if (choice == "About") {
+ JOptionPane.showMessageDialog(k.frame,
+ "Designed and Created By: Ayush Jain 1101CS09", "About",
+ JOptionPane.INFORMATION_MESSAGE);
+ } else if (choice == "Ok" || choice == "Cancel")
+ jd.setVisible(false);
+ }
+
+ public void stateChanged(ChangeEvent evt) {
+ JSlider slider = (JSlider) evt.getSource();
+ // if ((!slider.getValueIsAdjusting())&&jc1.isSelected()==false)
+ {
+ value = slider.getValue();
+ k.sound.volume(value);
+ }
+ }
+
+ public void itemStateChanged(ItemEvent e) {
+ JCheckBox h = (JCheckBox) e.getSource();
+ if (e.getStateChange() == ItemEvent.SELECTED && h.getText() == "Mute") {
+ k.sound.volume(0);
+ } else if (e.getStateChange() == ItemEvent.DESELECTED
+ && h.getText() == "Mute") {
+ k.sound.volume(value);
+ } else if (e.getStateChange() == ItemEvent.SELECTED
+ && h.getText() == "Enable Sound") {
+ k.sound.D = true;
+ } else if (e.getStateChange() == ItemEvent.DESELECTED
+ && h.getText() == "Enable Sound") {
+ if (k.sound.clip != null)
+ k.sound.clip.stop();
+ k.sound.D = false;
+ }
+ }
+}
diff --git a/src/main/java/Ques.java b/src/main/java/Ques.java
new file mode 100644
index 0000000..5bf07a0
--- /dev/null
+++ b/src/main/java/Ques.java
@@ -0,0 +1,121 @@
+import java.io.*;
+
+class Ques {
+ String ques, opta, optb, optc, optd, ans, sub;
+ String img, imgans;
+ static int category, category2, qno;
+
+ public Ques(String q, String a, String b, String c, String d, String e,
+ String ii, String f) {
+ try {
+ if (ii.equals(""))
+ img = null;
+ else
+ img = new String(ii).split(":")[0];
+ } catch (Exception ab) {
+ img = null;
+ }
+ try {
+ if (ii.equals(""))
+ imgans = null;
+ else
+ imgans = ii.split(":")[1];
+ } catch (Exception ab) {
+ imgans = null;
+ }
+ try {
+ if (f.equals(""))
+ sub = null;
+ else
+ sub = new String(f);
+ } catch (Exception ab) {
+ sub = null;
+ }
+ ques = q;
+ opta = a;
+ optb = b;
+ optc = c;
+ optd = d;
+ ans = e;
+ }
+
+ static Ques readNextQues() throws IOException {
+ qno++;
+ BufferedReader br;
+ System.out.println(CustomQuiz.rounds[category].file);
+ br = new BufferedReader(
+ new FileReader(CustomQuiz.rounds[category].file));
+ for (int i = 1; i <= (qno - 1) * 8; i++) {
+ br.readLine();
+ }
+ Ques ques = new Ques(br.readLine(), br.readLine(), br.readLine(),
+ br.readLine(), br.readLine(), br.readLine(), br.readLine(),
+ br.readLine());
+ br.close();
+ return ques;
+ }
+
+ static Ques readPreviousQues() throws IOException {
+ if (qno <= 1)
+ return new Ques(null, null, null, null, null, null, null, null);
+ qno--;
+ BufferedReader br;
+ br = new BufferedReader(
+ new FileReader(CustomQuiz.rounds[category].file));
+ for (int i = 1; i <= (qno - 1) * 8; i++) {
+ br.readLine();
+ }
+ Ques ques = new Ques(br.readLine(), br.readLine(), br.readLine(),
+ br.readLine(), br.readLine(), br.readLine(), br.readLine(),
+ br.readLine());
+ br.close();
+ return ques;
+ }
+
+ static Answer readAnswer() throws IOException {
+ BufferedReader br = new BufferedReader(new FileReader(
+ "Visual Answers.txt"));
+ for (int i = 1; i <= (qno - 1) * 2; i++) {
+ br.readLine();
+ }
+ Answer anss = new Answer(br.readLine(), br.readLine());
+ br.close();
+ return anss;
+ }
+
+ static String[] readCategories() {
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(
+ CustomQuiz.rounds[category].categoryFile));
+ String t = "", a[] = null;
+ a = br.readLine().split(":");
+ br.close();
+ int b[] = new int[a.length];
+ for (int i = 0; i < b.length; i++) {
+ b[i] = 0;
+ }
+ for (int i = 0; i < a.length; i++) {
+ br = new BufferedReader(new FileReader(
+ CustomQuiz.rounds[category].file));
+ while ((t = br.readLine()) != null) {
+ if (t.equals(a[i]))
+ b[i]++;
+ }
+ a[i] += "=" + b[i] + ":0";
+ }
+ br.close();
+ return a;
+ } catch (Exception nn) {
+ return null;
+ }
+ }
+}
+
+class Answer {
+ String ans, des;
+
+ public Answer(String a, String b) {
+ ans = a;
+ des = b;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Sound.java b/src/main/java/Sound.java
new file mode 100644
index 0000000..c2e9c73
--- /dev/null
+++ b/src/main/java/Sound.java
@@ -0,0 +1,49 @@
+import javax.sound.sampled.*;
+import java.io.*;
+
+class Sound extends Thread {
+ boolean D = true;
+ float vol = 60;
+ String str;
+ Clip clip;
+ AudioInputStream audioInputStream;
+ FloatControl gainControl;
+
+ void newClip(String s) {
+ str = s;
+ File soundFile = new File(str);
+ if (!soundFile.exists()) {
+ return;
+ }
+ AudioInputStream audioInputStream;
+ try {
+ audioInputStream = AudioSystem.getAudioInputStream(soundFile);
+ clip = AudioSystem.getClip();
+ clip.open(audioInputStream);
+ gainControl = (FloatControl) clip
+ .getControl(FloatControl.Type.MASTER_GAIN);
+ volume((double) vol);
+ } catch (UnsupportedAudioFileException e1) {
+ e1.printStackTrace();
+ return;
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ return;
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ return;
+ }
+ }
+
+ public void run() {
+ if (D == true)
+ clip.start();
+ }
+
+ public void volume(double gain) { // gain number between 0 and 100 (loudest)
+ float dB = (float) (Math.log(gain / 100) / Math.log(10.0) * 20.0);
+ if (gainControl != null)
+ gainControl.setValue(dB); // Reduce volume by 10 decibels.
+ vol = dB;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Splash.java b/src/main/java/Splash.java
new file mode 100644
index 0000000..8fb167d
--- /dev/null
+++ b/src/main/java/Splash.java
@@ -0,0 +1,79 @@
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+
+public class Splash extends Thread {
+ int time;
+ String file;
+
+ public Splash(String file, int time) {
+ this.file = file;
+ this.time = time;
+ }
+
+ JProgressBar pbar;
+ JWindow splash;
+
+ public void run() {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ splash = new JWindow();
+ pbar = new JProgressBar();
+ pbar.setMinimum(0);
+ pbar.setMaximum(100);
+ JPanel content = (JPanel) splash.getContentPane();
+ // int width = 259;
+ // int height = 210;
+ // Dimension screen =
+ // Toolkit.getDefaultToolkit().getScreenSize();
+ // int x = (screen.width-width)/2;
+ // int y = (screen.height-height)/2;
+ JLabel label = new JLabel(new ImageIcon(file));
+ content.add(label, BorderLayout.CENTER);
+ content.add(pbar, BorderLayout.SOUTH);
+ content.setBorder(BorderFactory.createLineBorder(
+ Color.black, 1));
+ splash.pack();
+ Dimension screen = Toolkit.getDefaultToolkit()
+ .getScreenSize();
+ Dimension sl = splash.getSize();
+ int x = (screen.width - sl.width) / 2;
+ int y = (screen.height - sl.height) / 2;
+ splash.setLocation(x, y);
+ splash.setVisible(true);
+ pbar.setStringPainted(true);
+ }
+ });
+ } catch (Exception e) {
+ }
+ updateBar();
+ }
+
+ void close() {
+ splash.setVisible(false);
+ }
+
+ int i = 0;
+ Timer ii;
+
+ public void updateBar() {
+ ii = new Timer(20, new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ try {
+ pbar.setValue(i);
+ pbar.updateUI();
+ } catch (Exception g) {
+ ii.stop();
+ close();
+ }
+ i = i + 1;
+ if (i > 100) {
+ ii.stop();
+ close();
+ }
+ }
+ });
+ ii.start();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/StopWatch.java b/src/main/java/StopWatch.java
new file mode 100644
index 0000000..b50db45
--- /dev/null
+++ b/src/main/java/StopWatch.java
@@ -0,0 +1,284 @@
+import java.awt.*;
+import java.awt.event.*;
+import java.io.File;
+
+import javax.swing.*;
+import javax.swing.border.*;
+
+@SuppressWarnings("serial")
+public class StopWatch extends JPanel {
+ private Timer myTimer1, myTimer0;
+ public static final int ONE_SEC = 1000; // time step in milliseconds
+ public static final int TENTH_SEC = 100;
+
+ private Font myClockFont;
+
+ JButton startBtn, stopBtn, resetBtn, resetBtn1, resetBtn2;
+ private JLabel timeLbl;
+ private JPanel topPanel, bottomPanel;
+
+ private int clockTick; // number of clock ticks; tick can be 1.0 s or 0.1 s
+ private double clockTime; // time in seconds
+ private String clockTimeString;
+ int i = 0;
+ Sound snd, snd2;
+
+ public StopWatch() {
+ clockTick = 600; // initial clock setting in clock ticks
+ clockTime = ((double) clockTick) / 10.0;
+
+ clockTimeString = new Integer((int) clockTime).toString();
+ myClockFont = new Font("Serif", Font.BOLD, 120);
+ snd = snd2 = null;
+
+ timeLbl = new JLabel();
+ timeLbl.setFont(myClockFont);
+ timeLbl.setText(clockTimeString);
+
+ startBtn = new JButton("Start");
+ stopBtn = new JButton("Stop");
+ resetBtn = new JButton("Res");
+ resetBtn1 = new JButton("Reset4");
+ resetBtn2 = new JButton("R30");
+
+ myTimer1 = new Timer(TENTH_SEC, new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ clockTick--;
+ if (clockTick <= 0 && i == 0) {
+ i = 1;
+ myTimer1.stop();
+ myTimer0 = new Timer(300, new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (topPanel.isOpaque()) {
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ } else {
+ topPanel.setOpaque(true);
+ topPanel.setBackground(Color.red);
+ topPanel.updateUI();
+ }
+ try {
+ snd.clip.stop();
+ snd = null;
+ } catch (Exception r) {
+ }
+ if (snd2 == null) {
+ Thread t1 = new Thread() {
+ public void run() {
+ snd2 = new Sound();
+ snd2.newClip(new File(CustomQuiz.resourcesLocation, "buzzer.wav").getAbsolutePath());
+ snd2.run();
+ }
+ };
+ t1.start();
+ }
+ }
+ });
+ myTimer0.start();
+ }
+ if (clockTick >= 5 && clockTick <= 100 && clockTick % 5 == 0) {
+ if (snd == null) {
+ Thread t1 = new Thread() {
+ public void run() {
+ snd = new Sound();
+ snd.newClip(new File(CustomQuiz.resourcesLocation, "last10.wav").getAbsolutePath());
+ snd.run();
+ }
+ };
+ t1.start();
+ }
+ if (topPanel.isOpaque()) {
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ } else {
+ topPanel.setOpaque(true);
+ topPanel.setBackground(Color.yellow);
+ topPanel.updateUI();
+ }
+ }
+ clockTime = ((double) clockTick) / 10.0;
+ clockTimeString = new Integer((int) clockTime).toString();
+ timeLbl.setText(clockTimeString);
+ // System.out.println(clockTime);
+ }
+ });
+
+ startBtn.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (i == 0)
+ myTimer1.start();
+ }
+ });
+
+ stopBtn.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ myTimer1.stop();
+ if (myTimer0 != null)
+ myTimer0.stop();
+ if (snd != null) {
+ snd.clip.stop();
+ snd = null;
+ }
+ if (snd2 != null) {
+ snd2.clip.stop();
+ snd2 = null;
+ }
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ }
+ });
+
+ resetBtn.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (myTimer0 != null)
+ myTimer0.stop();
+ if (snd != null) {
+ snd.clip.stop();
+ snd = null;
+ }
+ if (snd2 != null) {
+ snd2.clip.stop();
+ snd2 = null;
+ }
+ i = 0;
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ clockTick = 600;
+ clockTime = ((double) clockTick) / 10.0;
+ clockTimeString = new Integer((int) clockTime).toString();
+ timeLbl.setText(clockTimeString);
+ }
+ });
+
+ resetBtn1.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (myTimer0 != null)
+ myTimer0.stop();
+ if (snd != null) {
+ snd.clip.stop();
+ snd = null;
+ }
+ if (snd2 != null) {
+ snd2.clip.stop();
+ snd2 = null;
+ }
+ i = 0;
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ clockTick = 400;
+ clockTime = ((double) clockTick) / 10.0;
+ clockTimeString = new Integer((int) clockTime).toString();
+ timeLbl.setText(clockTimeString);
+ }
+ });
+
+ resetBtn2.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (myTimer0 != null)
+ myTimer0.stop();
+ if (snd != null) {
+ snd.clip.stop();
+ snd = null;
+ }
+ if (snd2 != null) {
+ snd2.clip.stop();
+ snd2 = null;
+ }
+ i = 0;
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ clockTick = 300;
+ clockTime = ((double) clockTick) / 10.0;
+ clockTimeString = new Integer((int) clockTime).toString();
+ timeLbl.setText(clockTimeString);
+ }
+ });
+ }// end of StopWatch constructor
+
+ void reset(final int time) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ if (myTimer0 != null)
+ myTimer0.stop();
+ if (snd != null) {
+ snd.clip.stop();
+ snd = null;
+ }
+ if (snd2 != null) {
+ snd2.clip.stop();
+ snd2 = null;
+ }
+ i = 0;
+ topPanel.setOpaque(false);
+ topPanel.updateUI();
+ clockTick = time*10;
+ clockTime = ((double) clockTick) / 10.0;
+ clockTimeString = new Integer((int) clockTime).toString();
+ timeLbl.setText(clockTimeString);
+ }
+ });
+ }
+
+ public void launchStopWatch() {
+ topPanel = new JPanel();
+ topPanel.setOpaque(false);
+ bottomPanel = new JPanel();
+ bottomPanel.setOpaque(false);
+ topPanel.add(timeLbl);
+ topPanel.setBorder(new CompoundBorder(BorderFactory.createLineBorder(
+ Color.black, 1), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
+ bottomPanel.add(startBtn);
+ bottomPanel.add(stopBtn);
+ bottomPanel.add(resetBtn);
+ bottomPanel.add(resetBtn2);
+ bottomPanel.setBorder(new CompoundBorder(BorderFactory
+ .createLineBorder(Color.black, 1), BorderFactory
+ .createEmptyBorder(5, 5, 5, 5)));
+
+ this.setLayout(new BorderLayout());
+
+ add(topPanel, BorderLayout.CENTER);
+ add(bottomPanel, BorderLayout.SOUTH);
+
+ setSize(300, 200);
+ setOpaque(false);
+
+ }// end of launchClock
+
+ @Override
+ protected void paintComponent(Graphics grphcs) {
+ Graphics2D g2d = (Graphics2D) grphcs;
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ GradientPaint gp = new GradientPaint(0, 0, getBackground().brighter()
+ .brighter(), getWidth(), getHeight(), getBackground().darker()
+ .darker());
+ g2d.setPaint(gp);
+ g2d.fillRect(0, 0, getWidth(), getHeight());
+ super.paintComponent(grphcs);
+ }
+
+ // public static void main(String[] args) {
+ // MyTestFrame myTestFrame1 = new MyTestFrame();
+ // }
+
+}// end of public class
+
+// Testing Code
+
+@SuppressWarnings("serial")
+class MyTestFrame extends JFrame {
+ StopWatch StopWatch1;
+
+ public MyTestFrame() {
+ super("My Stop Watch");
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ Container myPane = getContentPane();
+
+ StopWatch1 = new StopWatch();
+ StopWatch1.launchStopWatch();
+ myPane.add(StopWatch1);
+ pack();
+ setVisible(true);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Wifi.java b/src/main/java/Wifi.java
new file mode 100644
index 0000000..bcb4a41
--- /dev/null
+++ b/src/main/java/Wifi.java
@@ -0,0 +1,147 @@
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+class Wifi {
+
+ abstract class Thread1 extends Thread {
+ abstract public void sendMessage(String mess);
+ }
+
+ private ServerSocket serverSocket;
+ private boolean started;
+ private Thread serverThread;
+ int clientCount = 0;
+ static String chatHist = "";
+ List clientList;
+ String ip;
+ int port;
+
+ public Wifi() throws IOException {
+ serverSocket = new ServerSocket(9897, 50);
+ serverSocket.setReuseAddress(true);
+ clientList = new ArrayList();
+ started = false;
+ }
+
+ public void startServer() {
+ if (!started) {
+ started = true;
+ serverThread = new Thread() {
+ public void run() {
+ while (Wifi.this.started) {
+ Socket clientSocket = null;
+ try {
+ clientSocket = serverSocket.accept();
+ openClient(clientSocket);
+ System.out.println("joined");
+ try {
+ Thread.sleep(10);
+ } catch (Exception n) {
+ }
+ } catch (SocketException e) {
+ System.err.println("Server closed.");
+ } catch (IOException e) {
+ System.err.println("Accept failed.");
+ }
+ }
+ }
+ };
+ serverThread.start();
+ // new BServer(i,p).start();
+ System.out.println("started");
+ }
+ }
+
+ public void stopServer() {
+ this.started = false;
+ serverThread.interrupt();
+ try {
+ serverSocket.close();
+ } catch (IOException ex) {
+ System.err.println("Server stop failed.");
+ }
+ }
+
+ public void sendMulti(String mess) {
+ for (int i = 0; i < clientList.size(); i++) {
+ if (clientList.get(i).isAlive())
+ clientList.get(i).sendMessage(mess);
+ else
+ clientList.remove(i--);
+ }
+ }
+
+ int id = 0;
+
+ public void openClient(final Socket socket) {
+ clientCount++;
+ Thread1 g = new Thread1() {
+ BufferedReader in;
+ // PrintWriter out;
+ ObjectOutputStream objout;
+ public void run() {
+ try {
+ // out=new PrintWriter(socket.getOutputStream(),true);
+ in = new BufferedReader(new InputStreamReader(
+ socket.getInputStream()));
+ objout = new ObjectOutputStream(socket.getOutputStream());
+ // objout.enableReplaceObject(true);
+ // objin=new ObjectInputStream(socket.getInputStream());
+
+ String inputLine;//, outputLine;
+
+ while ((inputLine = (String) in.readLine()) != null) {
+ // System.out.println(inputLine);
+ processCommand(inputLine);
+ }
+
+ objout.close();
+ in.close();
+ socket.close();
+ } catch (Exception ex) {
+ System.out.println("Disconnected");
+ }
+ }
+
+ void processCommand(String command) {
+ String cmmd[] = command.split(":");
+ for (int i = 0; i < cmmd.length; i++)
+ cmmd[i] = cmmd[i].trim();
+ if (cmmd[0].equals("buzz")) {
+ System.out.println("BUZZ from team: " + cmmd[1]);
+ } else {
+ clientCount--;
+ clientList.remove(this);
+ try {
+ objout.writeObject(new String("101"));
+ objout.flush();
+ in.close();
+ objout.close();
+ socket.close();
+ return;
+ } catch (Exception e) {
+ in = null;
+ objout = null;
+ return;
+ }
+ }
+ }
+
+ public void sendMessage(final String mess) {
+ new Thread() {
+ public void run() {
+ try {
+ objout.reset();
+ objout.writeObject(mess);
+ objout.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }.start();
+ }
+ };
+ g.start();
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/BQuiz/FirstRound/firstround.txt b/src/main/resources/BQuiz/FirstRound/firstround.txt
new file mode 100644
index 0000000..99995d9
--- /dev/null
+++ b/src/main/resources/BQuiz/FirstRound/firstround.txt
@@ -0,0 +1,95 @@
+What is the full form of the abbreviation SL in Mercedes SL 500 ?
+A: Super Light
+B: Super Lock
+C: Super Loft
+D: Super Look
+1
+
+
+In 1918, after serving in the First World War in which company did Enzo Ferrari apply for a job but didn’t get it ?
+A: FIAT
+B: Ford
+C: Chrysler
+D: Maserati
+1
+
+
+What kind of vehicle was manufactured under the brand name “Fordson” started by Henry Ford and his son?
+A: Cars
+B: Bikes
+C: Tractors
+D: Trucks
+3
+
+
+In 1978, in which car did the world’s first 5 cylinder diesel engine premiere
+A: Audi A8
+B: Ford Shelby
+C: Audi Q10
+D: Audi 100
+4
+
+
+Which of the following car makers doesn’t produce Motorbikes ?
+A: BMW
+B: Suzuki
+C: Bristol
+D: Peugeot
+3
+
+
+In the name Wagon-R, 'R' stands for:
+A: Reserve
+B: Revolution
+C: Rover
+D: Recreation
+4
+
+
+What do Mazda and Volvo have in Common ?
+A: Both were once owned by Ford
+B: Both were once owned by FIAT
+C: Both were once owned by Maserati
+D: Both were once owned by De Tomasu
+1
+
+
+Ford expanded its reach into the luxury auto market through its acquisition of an auto company, named after a former US President whom Henry Ford admired. Name the President
+A: Abraham Lincoln
+B: George Washington
+C: Benjamin Franklin
+D: John Adams
+1
+
+
+Ford and Renault entered India through joint ventures with
+A: Mahindra
+B: Maruti
+C: Tata
+D: Hindustan Motors
+1
+
+
+Pajero is also known as:
+A: Corvatu
+B: Shogun
+C: Starcar
+D: Cheetah
+2
+
+
+Find out the wrong link of the subsidiaries and the parent companies
+A: Lexus – Toyota
+B: Opel – General Motors
+C: Audi – Volkswagen Group
+D: Nissan – Honda
+3
+
+
+Which is word’s top selling hybrid car ?
+A: Toyota Avalon
+B: Honda CRV Hybrid
+C: Toyota Prius
+D: Lexus RX 450h
+3
+
diff --git a/src/main/resources/BQuiz/SecondRound/secround.txt b/src/main/resources/BQuiz/SecondRound/secround.txt
new file mode 100644
index 0000000..9c1b390
--- /dev/null
+++ b/src/main/resources/BQuiz/SecondRound/secround.txt
@@ -0,0 +1,95 @@
+Audi's slogan is Vorsprung durch Technik, meaning
+A: Advancement through Technology
+B: Engineered to perfection
+C: Technology is the future
+D: Technology you can enjoy
+1
+
+
+BMW vehicles follow a certain nomenclature, usually a 3 digit number is followed by 1 or 2 letters. In the BMW 116i, what does "i" signify ?
+A: Fuel injected
+B: Turbo diesel
+C: Long wheelbase
+D: Cabriolet
+1
+
+
+Volkswagen produced and sold neat ethanol vehicles in which country?
+A: Germany
+B: Brazil
+C: USA
+D: China
+2
+
+
+The top motor vehicle manufacturing company in the world is :
+A: Hyundai Motors
+B: Volkswagen
+C: Toyota
+D: General Motors
+4
+
+
+The Bugatti Veyron super sport is the world's most expensive car. Which is the world's second most expensive car ?
+A: Aston Martin One
+B: Pagani Zonda Cinque Roadster
+C: Lamborghini Reventon
+D: Koenigsegg Agera
+1
+
+
+The company is headquartered in Ingolstadt, Germany, and has been a wholly owned (99.55%) subsidiary of Volkswagen AG since 1966. Volkswagen relaunched the X brand with the 1965 introduction of the X F103 series. Identify X ?
+A: Lamborghini
+B: Bentley
+C: Audi
+D: Skoda
+3
+
+
+In the movie ‘Gone in 60 seconds’ Nicolas Cage could not get away with Eleanor. What kind of car is she ?
+A: Chevrolet Corvette
+B: Ferrari Enzo
+C: Shelby Mustang GT
+D: Dodge Viper
+3
+
+
+Which make of cars has a nickname "silver star" ?
+A: Mercedes Benz
+B: Toyota
+C: Hyundai
+D: Maserati
+1
+
+
+Name the pin that connects piston to the connecting rod ?
+A: Clevis pin
+B: Gudgeon Pin
+C: Sarrus pin
+D: Klann pin
+2
+
+
+Buick is a premium brand of ________.
+A: Hyundai Motors
+B: Koeinigsegg
+C: General Motors
+D: Volkswagen
+3
+
+
+"Live tomorrow today" is the tagline of __________.
+A: Toyota Etios
+B: Honda Civic
+C: Toyota Corolla Altis
+D: Hyundai Accent
+1
+
+
+What is the performance brand "Holly" BEST known for ?
+A: Carburetors
+B: Turbos
+C: Brakes
+D: Exhaust Systems
+1
+
diff --git a/src/main/resources/BQuiz/ThirdRound/thirdround.txt b/src/main/resources/BQuiz/ThirdRound/thirdround.txt
new file mode 100644
index 0000000..e3acc34
--- /dev/null
+++ b/src/main/resources/BQuiz/ThirdRound/thirdround.txt
@@ -0,0 +1,79 @@
+Google is recently in collaboration with a company to launch its latest version of android in India. Name the company ?
+
+
+
+
+Nestle Kitkat.
+
+
+What is the name of the CEO of a multibillion dollar company who announced his retirement in August this year ? Hint for the name of the company: Not everything is macro and not everything is hard. (microsoft)
+
+
+
+
+Steve Ballmer.
+
+
+Founders of google. Larry Page and ______ ?
+
+
+
+
+Sergey Brin
+
+
+Nestle is a company based in which country?
+A: USA
+B: Switzerland
+C: South Africa
+D: India
+2
+
+
+Which fabric company has the slogan - 'India's Family Store'?
+A: Pantaloon
+B: Provouge
+C: Hirawats
+D: Peter England
+1
+
+
+As per TRAI guidelines how many minutes of advertising is allowed for 60 mins of programming on TV ?
+
+
+
+
+Ans. 12 minutes
+
+
+Which car manufacturer has promised that they will launch self driving cars by 2020 ?
+
+
+
+
+Ans. Nissan
+
+
+Which publication has the slogan ‘Capitalist Tool” ?
+
+
+
+
+Ans. Forbes magazine
+
+
+Three of the top investors in a company want to throw out person X as Chairman. His holding in the company is currently 4.5 % now. Who is person X ?
+
+
+
+
+Ans: Bill Gates.
+
+
+80% of this drink comes from Kentucky, USA. It is named after a county, which was named after a French gallant family. In India more famous as a biscuit. Name the drink.
+
+
+
+
+Ans. Bourbon
+
diff --git a/src/main/resources/BQuiz/default.jpg b/src/main/resources/BQuiz/default.jpg
new file mode 100644
index 0000000..db6d7e6
Binary files /dev/null and b/src/main/resources/BQuiz/default.jpg differ
diff --git a/src/main/resources/BQuiz/splash.png b/src/main/resources/BQuiz/splash.png
new file mode 100644
index 0000000..02d24c9
Binary files /dev/null and b/src/main/resources/BQuiz/splash.png differ
diff --git a/src/main/resources/confg.xml b/src/main/resources/confg.xml
new file mode 100644
index 0000000..1013df3
--- /dev/null
+++ b/src/main/resources/confg.xml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/resources/5050.gif b/src/main/resources/resources/5050.gif
new file mode 100644
index 0000000..15174c9
Binary files /dev/null and b/src/main/resources/resources/5050.gif differ
diff --git a/src/main/resources/resources/a.wav b/src/main/resources/resources/a.wav
new file mode 100644
index 0000000..4b501d8
Binary files /dev/null and b/src/main/resources/resources/a.wav differ
diff --git a/src/main/resources/resources/audio.wav b/src/main/resources/resources/audio.wav
new file mode 100644
index 0000000..fe43915
Binary files /dev/null and b/src/main/resources/resources/audio.wav differ
diff --git a/src/main/resources/resources/b.wav b/src/main/resources/resources/b.wav
new file mode 100644
index 0000000..2ba2fa4
Binary files /dev/null and b/src/main/resources/resources/b.wav differ
diff --git a/src/main/resources/resources/buzzer.wav b/src/main/resources/resources/buzzer.wav
new file mode 100644
index 0000000..47cb3cc
Binary files /dev/null and b/src/main/resources/resources/buzzer.wav differ
diff --git a/src/main/resources/resources/carcrash.wav b/src/main/resources/resources/carcrash.wav
new file mode 100644
index 0000000..64ebe03
Binary files /dev/null and b/src/main/resources/resources/carcrash.wav differ
diff --git a/src/main/resources/resources/cars.wav b/src/main/resources/resources/cars.wav
new file mode 100644
index 0000000..c5bfbf3
Binary files /dev/null and b/src/main/resources/resources/cars.wav differ
diff --git a/src/main/resources/resources/kbc.wav b/src/main/resources/resources/kbc.wav
new file mode 100644
index 0000000..cf556c4
Binary files /dev/null and b/src/main/resources/resources/kbc.wav differ
diff --git a/src/main/resources/resources/last10.wav b/src/main/resources/resources/last10.wav
new file mode 100644
index 0000000..e3df451
Binary files /dev/null and b/src/main/resources/resources/last10.wav differ
diff --git a/src/main/resources/resources/paf.gif b/src/main/resources/resources/paf.gif
new file mode 100644
index 0000000..a20f774
Binary files /dev/null and b/src/main/resources/resources/paf.gif differ
diff --git a/src/main/resources/resources/poll.gif b/src/main/resources/resources/poll.gif
new file mode 100644
index 0000000..f1e893c
Binary files /dev/null and b/src/main/resources/resources/poll.gif differ