-
Notifications
You must be signed in to change notification settings - Fork 1
/
DD_Wrong_Ans.java
103 lines (85 loc) · 3.67 KB
/
DD_Wrong_Ans.java
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
// Import Statements
import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import layout.TableLayout;
/**
* This class creates the Double Dip Wrong Answer Dialog. It shows up when the
* user selects Double Dip and their first selection is wrong.
*
* @author (Taranveer Virk && Gurbir Dhulla)
* @version (v.1 12JAN2011)
*/
public class DD_Wrong_Ans extends Millionaire // name of the class
{
// Variables Declared
static ImagePanel caP;
static JDialog ansCDisp = new JDialog ();
static JPanel display = new JPanel ();
static String correctAB = "images/AnsWrong.png";
private static double size[][] = {{TableLayout.FILL}, {0.05, 0.1, 0.45, 0.1, TableLayout.FILL}};
private static double size3 [][] = {{0.605, 0.35, 0.05}, {0.865, 0.095, 0.1}};
static JLabel continueL = new JLabel ("Continue");
static JLabel correctL = new JLabel ("WRONG");
static JLabel timeL = new JLabel ("");
static TransparentButton continueB = new TransparentButton ("");
static TransparentButtonHandler handlerC = new TransparentButtonHandler ();
/**
* This method creates the Double Dip Wrong Answer Dialog
*/
public static void disp () throws IOException
{
wrongMP3.play ();
// Adding Button To Handler
continueB.addActionListener (handlerC);
//Setting Up Labels
continueL.setFont (new Font("Serif", Font.BOLD, 20));
continueL.setForeground (Color.WHITE);
correctL.setFont (new Font("Serif", Font.BOLD, 24));
correctL.setForeground (Color.RED);
timeL.setText ("Incorrect Answer, Try Again");
timeL.setFont (new Font("Serif", Font.BOLD, 20));
timeL.setForeground (Color.WHITE);
// Setting properties of Main Panel
caP = new ImagePanel(new ImageIcon(correctAB).getImage());
caP.setLayout (new TableLayout (size));
caP.setOpaque (false);
caP.setVisible (true);
// Setting Invisible Display Panel for Holding Continue Button / Label
display.setLayout (new TableLayout (size3));
display.setOpaque (false);
display.setVisible (true);
display.add (continueB, "1, 1");
display.add (continueL, "1, 1, c, b");
// Adding Components to Main Panel
caP.add (display, "0, 0, 0, 4");
caP.add (correctL, "0, 1, c, c");
caP.add (timeL, "0, 3, c, c");
// Dialog Box Setup and Display
ansCDisp.setUndecorated(true); // Hides the Top Bar
ansCDisp.setContentPane (caP); // Adding Panel to Dialog
ansCDisp.pack(); // Packs the Dialog
ansCDisp.validate(); // Validates the Dialog
ansCDisp.setModal(true); // Makes it Compulsory for User to go through the Dialog
ansCDisp.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // Disables the Close Button
ansCDisp.setLocationRelativeTo(null); // Centers Panel on Screen
ansCDisp.setVisible(true); // Makes Dialog Visible
ansCDisp.setResizable (false); // Disables the Maximize Button :)
}
private static class TransparentButtonHandler implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
if (event.getSource () == continueB) // Continue Button
{
wrongMP3.close();
dd2MP3.play();
timer.start();
ansCDisp.dispose();
}
}
}
}