Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- public class DealOrNoDeal {
- public static int cases[]=new int[26];
- private JFrame frame;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- DealOrNoDeal window = new DealOrNoDeal();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- int[] money = {1,2,5,10,25,50,75,100,200,300,400,500,750,1000,5000,10000,25000,50000,75000,100000,200000,300000,400000,500000,750000,1000000};
- Random random = new Random();
- int index = 0;
- firstLoop:
- while(cases[25]==0){
- int randomChosenIndex = random.nextInt(money.length);
- int randomChosenValueFromMoney = money[randomChosenIndex];
- for (int i = 0; i < index; i++) {
- if (cases[i]==randomChosenValueFromMoney) {
- continue firstLoop;
- }
- }
- cases[index++] = randomChosenValueFromMoney;
- }
- }
- /**
- * Create the application.
- */
- public DealOrNoDeal() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- public int picked;
- public int cases26 = cases[0];
- public int casesPicked = 0;
- public int DealerOffer = 0;
- final JLabel lblPickAmount = new JLabel("8");
- private void initialize() {
- final JButton btnNext = new JButton("Next");
- final JButton btnPause2S = new JButton("pause");
- final JButton btnButton = new JButton("New button");
- final JButton btnNoDeal = new JButton("No Deal");
- frame = new JFrame();
- frame.setBounds(100, 100, 1450, 890);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- final JLabel lblBanker = new JLabel("The banker is offering: ");
- lblBanker.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblBanker.setBounds(459, 677, 225, 47);
- frame.getContentPane().add(lblBanker);
- lblBanker.setVisible(false);
- final JLabel lblBankerOffer = new JLabel(" ");
- lblBankerOffer.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblBankerOffer.setBounds(696, 677, 100, 47);
- frame.getContentPane().add(lblBankerOffer);
- lblBankerOffer.setVisible(false);
- final JButton btnDeal = new JButton("Deal");
- btnDeal.setVisible(false);
- btnDeal.setEnabled(false);
- btnDeal.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- lblBanker.setVisible(false);
- lblBankerOffer.setVisible(false);
- btnDeal.setVisible(false);
- btnNoDeal.setVisible(false);
- btnDeal.setEnabled(false);
- btnNoDeal.setEnabled(false);
- }
- });
- btnDeal.setBounds(535, 751, 100, 63);
- frame.getContentPane().add(btnDeal);
- //------------------------No Deal---------------------
- btnNoDeal.setVisible(false);
- btnNoDeal.setEnabled(false);
- btnNoDeal.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- lblBanker.setVisible(false);
- lblBankerOffer.setVisible(false);
- btnDeal.setVisible(false);
- btnNoDeal.setVisible(false);
- btnDeal.setEnabled(false);
- btnNoDeal.setEnabled(false);
- }
- });
- btnNoDeal.setBounds(785, 751, 100, 63);
- frame.getContentPane().add(btnNoDeal);
- JLabel lblYourCaseLabel = new JLabel("Your case");
- lblYourCaseLabel.setFont(new Font("Tahoma", Font.PLAIN, 25));
- lblYourCaseLabel.setBounds(136, 708, 119, 47);
- frame.getContentPane().add(lblYourCaseLabel);
- final JLabel lblYourCase = new JLabel("");
- lblYourCase.setFont(new Font("Tahoma", Font.PLAIN, 25));
- lblYourCase.setBounds(271, 708, 74, 47);
- frame.getContentPane().add(lblYourCase);
- final JLabel lblValue1 = new JLabel("$1");
- lblValue1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue1.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue1.setBounds(40, 109, 100, 30);
- frame.getContentPane().add(lblValue1);
- final JLabel lblValue2 = new JLabel("$2");
- lblValue2.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue2.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue2.setBounds(40, 152, 100, 30);
- frame.getContentPane().add(lblValue2);
- final JLabel lblValue5 = new JLabel("$5");
- lblValue5.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue5.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue5.setBounds(40, 195, 100, 30);
- frame.getContentPane().add(lblValue5);
- final JLabel lblValue10 = new JLabel("$10");
- lblValue10.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue10.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue10.setBounds(40, 238, 100, 30);
- frame.getContentPane().add(lblValue10);
- final JLabel lblValue25 = new JLabel("$25");
- lblValue25.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue25.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue25.setBounds(40, 281, 100, 30);
- frame.getContentPane().add(lblValue25);
- final JLabel lblValue50 = new JLabel("$50");
- lblValue50.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue50.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue50.setBounds(40, 324, 100, 30);
- frame.getContentPane().add(lblValue50);
- final JLabel lblValue75 = new JLabel("$75");
- lblValue75.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue75.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue75.setBounds(40, 367, 100, 30);
- frame.getContentPane().add(lblValue75);
- final JLabel lblValue100 = new JLabel("$100");
- lblValue100.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue100.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue100.setBounds(40, 410, 100, 30);
- frame.getContentPane().add(lblValue100);
- final JLabel lblValue200 = new JLabel("$200");
- lblValue200.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue200.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue200.setBounds(40, 453, 100, 30);
- frame.getContentPane().add(lblValue200);
- final JLabel lblValue300 = new JLabel("$300");
- lblValue300.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue300.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue300.setBounds(40, 496, 100, 30);
- frame.getContentPane().add(lblValue300);
- final JLabel lblValue400 = new JLabel("$400");
- lblValue400.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue400.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue400.setBounds(40, 539, 100, 30);
- frame.getContentPane().add(lblValue400);
- final JLabel lblValue500 = new JLabel("$500");
- lblValue500.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue500.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue500.setBounds(40, 582, 100, 30);
- frame.getContentPane().add(lblValue500);
- final JLabel lblValue750 = new JLabel("$750");
- lblValue750.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue750.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue750.setBounds(40, 625, 100, 30);
- frame.getContentPane().add(lblValue750);
- final JLabel lblValue1000 = new JLabel("$1,000");
- lblValue1000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue1000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue1000.setBounds(1280, 109, 100, 30);
- frame.getContentPane().add(lblValue1000);
- final JLabel lblValue5000 = new JLabel("$5,000");
- lblValue5000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue5000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue5000.setBounds(1280, 152, 100, 30);
- frame.getContentPane().add(lblValue5000);
- final JLabel lblValue10000 = new JLabel("$10,000");
- lblValue10000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue10000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue10000.setBounds(1280, 195, 100, 30);
- frame.getContentPane().add(lblValue10000);
- final JLabel lblValue25000 = new JLabel("$25,000");
- lblValue25000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue25000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue25000.setBounds(1280, 238, 100, 30);
- frame.getContentPane().add(lblValue25000);
- final JLabel lblValue50000 = new JLabel("$50,000");
- lblValue50000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue50000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue50000.setBounds(1280, 281, 100, 30);
- frame.getContentPane().add(lblValue50000);
- final JLabel lblValue75000 = new JLabel("$75,000");
- lblValue75000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue75000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue75000.setBounds(1280, 324, 100, 30);
- frame.getContentPane().add(lblValue75000);
- final JLabel lblValue100000 = new JLabel("$100,000");
- lblValue100000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue100000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue100000.setBounds(1280, 367, 100, 30);
- frame.getContentPane().add(lblValue100000);
- final JLabel lblValue200000 = new JLabel("$200,000");
- lblValue200000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue200000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue200000.setBounds(1280, 410, 100, 30);
- frame.getContentPane().add(lblValue200000);
- final JLabel lblValue300000 = new JLabel("$300,000");
- lblValue300000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue300000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue300000.setBounds(1280, 453, 100, 30);
- frame.getContentPane().add(lblValue300000);
- final JLabel lblValue400000 = new JLabel("$400,000");
- lblValue400000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue400000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue400000.setBounds(1280, 496, 100, 30);
- frame.getContentPane().add(lblValue400000);
- final JLabel lblValue500000 = new JLabel("$500,000");
- lblValue500000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue500000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue500000.setBounds(1280, 539, 100, 30);
- frame.getContentPane().add(lblValue500000);
- final JLabel lblValue750000 = new JLabel("$750,000");
- lblValue750000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue750000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue750000.setBounds(1280, 582, 100, 30);
- frame.getContentPane().add(lblValue750000);
- final JLabel lblValue1000000 = new JLabel("$1,000,000");
- lblValue1000000.setHorizontalAlignment(SwingConstants.RIGHT);
- lblValue1000000.setFont(new Font("Tahoma", Font.PLAIN, 20));
- lblValue1000000.setBounds(1280, 625, 100, 30);
- frame.getContentPane().add(lblValue1000000);
- final JButton btn10 = new JButton("10");
- btn10.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn10.setEnabled(false);
- lblYourCase.setText("10");
- btn10.setVisible(false);
- }
- else
- {
- btn10.setText(Integer.toString(cases[10]));
- picked = cases[10];
- btn10.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn10.setBounds(660, 410, 100, 100);
- frame.getContentPane().add(btn10);
- final JButton btn3 = new JButton("3");
- btn3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn3.setEnabled(false);
- btn3.setVisible(false);
- lblYourCase.setText("3");
- }
- else
- {
- btn3.setText(Integer.toString(cases[3]));
- picked = cases[3];
- btn3.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn3.setBounds(598, 539, 100, 100);
- frame.getContentPane().add(btn3);
- final JButton btn2 = new JButton("2");
- btn2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn2.setEnabled(false);
- btn2.setVisible(false);
- lblYourCase.setText("2");
- }
- else
- {
- btn2.setText(Integer.toString(cases[2]));
- picked = cases[2];
- btn2.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn2.setBounds(473, 539, 100, 100);
- frame.getContentPane().add(btn2);
- final JButton btn9 = new JButton("9");
- btn9.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn9.setEnabled(false);
- btn9.setVisible(false);
- lblYourCase.setText("9");
- }
- else
- {
- btn9.setText(Integer.toString(cases[9]));
- picked = cases[9];
- btn9.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn9.setBounds(535, 410, 100, 100);
- frame.getContentPane().add(btn9);
- final JButton btn8 = new JButton("8");
- btn8.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn8.setEnabled(false);
- btn8.setVisible(false);
- lblYourCase.setText("8");
- }
- else
- {
- btn8.setText(Integer.toString(cases[8]));
- picked = cases[8];
- btn8.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn8.setBounds(410, 410, 100, 100);
- frame.getContentPane().add(btn8);
- final JButton btn7 = new JButton("7");
- btn7.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn7.setEnabled(false);
- btn7.setVisible(false);
- lblYourCase.setText("7");
- }
- else
- {
- btn7.setText(Integer.toString(cases[7]));
- picked = cases[7];
- btn7.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn7.setBounds(285, 410, 100, 100);
- frame.getContentPane().add(btn7);
- final JButton btn11 = new JButton("11");
- btn11.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn11.setEnabled(false);
- btn11.setVisible(false);
- lblYourCase.setText("11");
- }
- else
- {
- btn11.setText(Integer.toString(cases[11]));
- picked = cases[11];
- btn11.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn11.setBounds(785, 410, 100, 100);
- frame.getContentPane().add(btn11);
- final JButton btn12 = new JButton("12");
- btn12.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn12.setEnabled(false);
- btn12.setVisible(false);
- lblYourCase.setText("12");
- }
- else
- {
- btn12.setText(Integer.toString(cases[12]));
- picked = cases[12];
- btn12.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn12.setBounds(910, 410, 100, 100);
- frame.getContentPane().add(btn12);
- final JButton btn13 = new JButton("13");
- btn13.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn13.setEnabled(false);
- btn13.setVisible(false);
- lblYourCase.setText("13");
- }
- else
- {
- btn13.setText(Integer.toString(cases[13]));
- picked = cases[13];
- btn13.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn13.setBounds(1035, 410, 100, 100);
- frame.getContentPane().add(btn13);
- final JButton btn4 = new JButton("4");
- btn4.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn4.setEnabled(false);
- btn4.setVisible(false);
- lblYourCase.setText("4");
- }
- else
- {
- btn4.setText(Integer.toString(cases[4]));
- picked = cases[4];
- btn4.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn4.setBounds(722, 539, 100, 100);
- frame.getContentPane().add(btn4);
- final JButton btn5 = new JButton("5");
- btn5.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn5.setEnabled(false);
- btn5.setVisible(false);
- lblYourCase.setText("5");
- }
- else
- {
- btn5.setText(Integer.toString(cases[5]));
- picked = cases[5];
- btn5.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn5.setBounds(847, 539, 100, 100);
- frame.getContentPane().add(btn5);
- final JButton btn6 = new JButton("6");
- btn6.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn6.setEnabled(false);
- btn6.setVisible(false);
- lblYourCase.setText("6");
- }
- else
- {
- btn6.setText(Integer.toString(cases[6]));
- picked = cases[6];
- btn6.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn6.setBounds(972, 539, 100, 100);
- frame.getContentPane().add(btn6);
- final JButton btn1 = new JButton("1");
- btn1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- if (casesPicked==0)
- {
- btn1.setEnabled(false);
- btn1.setVisible(false);
- lblYourCase.setText("1");
- }
- else
- {
- btn1.setText(Integer.toString(cases[1]));
- picked = cases[1];
- btn1.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn1.setBounds(348, 539, 100, 100);
- frame.getContentPane().add(btn1);
- final JButton btn14 = new JButton("14");
- btn14.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn14.setEnabled(false);
- btn14.setVisible(false);
- lblYourCase.setText("14");
- }
- else
- {
- btn14.setText(Integer.toString(cases[14]));
- picked = cases[14];
- btn14.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn14.setBounds(285, 287, 100, 100);
- frame.getContentPane().add(btn14);
- final JButton btn21 = new JButton("21");
- btn21.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn21.setEnabled(false);
- btn21.setVisible(false);
- lblYourCase.setText("21");
- }
- else
- {
- btn21.setText(Integer.toString(cases[21]));
- picked = cases[21];
- btn21.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn21.setBounds(348, 163, 100, 100);
- frame.getContentPane().add(btn21);
- final JButton btn15 = new JButton("15");
- btn15.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn15.setEnabled(false);
- btn15.setVisible(false);
- lblYourCase.setText("15");
- }
- else
- {
- btn15.setText(Integer.toString(cases[15]));
- picked = cases[15];
- btn15.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn15.setBounds(410, 281, 100, 100);
- frame.getContentPane().add(btn15);
- final JButton btn16 = new JButton("16");
- btn16.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn16.setEnabled(false);
- btn16.setVisible(false);
- lblYourCase.setText("16");
- }
- else
- {
- btn16.setText(Integer.toString(cases[16]));
- picked = cases[16];
- btn16.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn16.setBounds(535, 281, 100, 100);
- frame.getContentPane().add(btn16);
- final JButton btn17 = new JButton("17");
- btn17.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn17.setEnabled(false);
- btn17.setVisible(false);
- lblYourCase.setText("17");
- }
- else
- {
- btn17.setText(Integer.toString(cases[17]));
- picked = cases[17];
- btn17.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn17.setBounds(660, 281, 100, 100);
- frame.getContentPane().add(btn17);
- final JButton btn18 = new JButton("18");
- btn18.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn18.setEnabled(false);
- btn18.setVisible(false);
- lblYourCase.setText("18");
- }
- else
- {
- btn18.setText(Integer.toString(cases[18]));
- picked = cases[18];
- btn18.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn18.setBounds(785, 281, 100, 100);
- frame.getContentPane().add(btn18);
- final JButton btn19 = new JButton("19");
- btn19.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn19.setEnabled(false);
- btn19.setVisible(false);
- lblYourCase.setText("19");
- }
- else
- {
- btn19.setText(Integer.toString(cases[19]));
- picked = cases[19];
- btn19.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn19.setBounds(910, 281, 100, 100);
- frame.getContentPane().add(btn19);
- final JButton btn20 = new JButton("20");
- btn20.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn20.setEnabled(false);
- btn20.setVisible(false);
- lblYourCase.setText("20");
- }
- else
- {
- btn20.setText(Integer.toString(cases[20]));
- picked = cases[20];
- btn20.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn20.setBounds(1035, 281, 100, 100);
- frame.getContentPane().add(btn20);
- final JButton btn22 = new JButton("22");
- btn22.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn22.setEnabled(false);
- btn22.setVisible(false);
- lblYourCase.setText("22");
- }
- else
- {
- btn22.setText(Integer.toString(cases[22]));
- picked = cases[22];
- btn22.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn22.setBounds(473, 163, 100, 100);
- frame.getContentPane().add(btn22);
- final JButton btn23 = new JButton("23");
- btn23.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn23.setEnabled(false);
- btn23.setVisible(false);
- lblYourCase.setText("23");
- }
- else
- {
- btn23.setText(Integer.toString(cases[23]));
- picked = cases[23];
- btn23.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn23.setBounds(598, 163, 100, 100);
- frame.getContentPane().add(btn23);
- final JButton btn24 = new JButton("24");
- btn24.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn24.setEnabled(false);
- btn24.setVisible(false);
- lblYourCase.setText("24");
- }
- else
- {
- btn24.setText(Integer.toString(cases[24]));
- picked = cases[24];
- btn24.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn24.setBounds(722, 163, 100, 100);
- frame.getContentPane().add(btn24);
- final JButton btn25 = new JButton("25");
- btn25.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn25.setEnabled(false);
- btn25.setVisible(false);
- lblYourCase.setText("25");
- }
- else
- {
- btn25.setText(Integer.toString(cases[25]));
- picked = cases[25];
- btn25.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn25.setBounds(847, 163, 100, 100);
- frame.getContentPane().add(btn25);
- final JButton btn26 = new JButton("26");
- btn26.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==0)
- {
- btn26.setEnabled(false);
- btn26.setVisible(false);
- lblYourCase.setText("26");
- }
- else
- {
- btn20.setText(Integer.toString(cases26));
- picked = cases26;
- btn26.setEnabled(false);
- btnNext.doClick();
- }
- casesPicked++;
- }
- });
- btn26.setBounds(972, 163, 100, 100);
- frame.getContentPane().add(btn26);
- JLabel lblTitle = new JLabel("DEAL OR NO DEAL");
- lblTitle.setFont(new Font("Copperplate Gothic Bold", Font.PLAIN, 35));
- lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
- lblTitle.setBounds(348, 13, 724, 70);
- frame.getContentPane().add(lblTitle);
- //-----------------Button Next-----------------
- btnNext.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (picked==1)
- {
- lblValue1.setForeground(Color.red);
- }
- else if (picked==2)
- {
- lblValue2.setForeground(Color.red);
- }
- else if (picked==5)
- {
- lblValue5.setForeground(Color.red);
- }
- else if (picked==10)
- {
- lblValue10.setForeground(Color.red);
- }
- else if (picked==25)
- {
- lblValue25.setForeground(Color.red);
- }
- else if (picked==50)
- {
- lblValue50.setForeground(Color.red);
- }
- else if (picked==75)
- {
- lblValue75.setForeground(Color.red);
- }
- else if (picked==100)
- {
- lblValue100.setForeground(Color.red);
- }
- else if (picked==200)
- {
- lblValue200.setForeground(Color.red);
- }
- else if (picked==300)
- {
- lblValue300.setForeground(Color.red);
- }
- else if (picked==400)
- {
- lblValue400.setForeground(Color.red);
- }
- else if (picked==500)
- {
- lblValue500.setForeground(Color.red);
- }
- else if (picked==750)
- {
- lblValue750.setForeground(Color.red);
- }
- else if (picked==1000)
- {
- lblValue1000.setForeground(Color.red);
- }
- else if (picked==5000)
- {
- lblValue5000.setForeground(Color.red);
- }
- else if (picked==10000)
- {
- lblValue10000.setForeground(Color.red);
- }
- else if (picked==25000)
- {
- lblValue25000.setForeground(Color.red);
- }
- else if (picked==50000)
- {
- lblValue50000.setForeground(Color.red);
- }
- else if (picked==75000)
- {
- lblValue75000.setForeground(Color.red);
- }
- else if (picked==100000)
- {
- lblValue100000.setForeground(Color.red);
- }
- else if (picked==200000)
- {
- lblValue200000.setForeground(Color.red);
- }
- else if (picked==300000)
- {
- lblValue300000.setForeground(Color.red);
- }
- else if (picked==400000)
- {
- lblValue400000.setForeground(Color.red);
- }
- else if (picked==500000)
- {
- lblValue500000.setForeground(Color.red);
- }
- else if (picked==750000)
- {
- lblValue750000.setForeground(Color.red);
- }
- else if (picked==1000000)
- {
- lblValue1000000.setForeground(Color.red);
- }
- else
- {
- lblValue1000000.setForeground(Color.green);
- }
- btnButton.doClick();
- }
- });
- btnNext.setBounds(1363, 784, 57, 30);
- frame.getContentPane().add(btnNext);
- //-----------Pause 2 Seconds-------------------------------------------
- btnPause2S.setVisible(false);
- btnPause2S.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- Thread.sleep(2000); //1000 milliseconds is one second.
- } catch(InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
- });
- btnPause2S.setBounds(1400, 746, 20, 25);
- frame.getContentPane().add(btnPause2S);
- //--------------------Do button--------------------
- btnButton.setVisible(false);
- btnButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (casesPicked==8)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==14)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==18)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==21)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==23)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==24)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==25)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else if (casesPicked==26)
- {
- lblBanker.setVisible(true);
- lblBankerOffer.setVisible(true);
- btnDeal.setVisible(true);
- btnNoDeal.setVisible(true);
- btnDeal.setEnabled(true);
- btnNoDeal.setEnabled(true);
- lblBankerOffer.setText("$300");
- }
- else
- {
- }
- }
- });
- btnButton.setBounds(1297, 746, 97, 25);
- frame.getContentPane().add(btnButton);
- btnNext.setVisible(false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement