Advertisement
Guest User

Untitled

a guest
Nov 8th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.48 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. public class DealOrNoDeal {
  4. public static int cases[]=new int[26];
  5.  
  6. private JFrame frame;
  7.  
  8. /**
  9. * Launch the application.
  10. */
  11. public static void main(String[] args) {
  12. EventQueue.invokeLater(new Runnable() {
  13. public void run() {
  14. try {
  15. DealOrNoDeal window = new DealOrNoDeal();
  16. window.frame.setVisible(true);
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. });
  22.  
  23.  
  24.  
  25.  
  26. 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};
  27. Random random = new Random();
  28. int index = 0;
  29. firstLoop:
  30. while(cases[25]==0){
  31. int randomChosenIndex = random.nextInt(money.length);
  32. int randomChosenValueFromMoney = money[randomChosenIndex];
  33. for (int i = 0; i < index; i++) {
  34. if (cases[i]==randomChosenValueFromMoney) {
  35. continue firstLoop;
  36. }
  37. }
  38. cases[index++] = randomChosenValueFromMoney;
  39. }
  40.  
  41.  
  42. }
  43.  
  44. /**
  45. * Create the application.
  46. */
  47. public DealOrNoDeal() {
  48. initialize();
  49. }
  50.  
  51. /**
  52. * Initialize the contents of the frame.
  53. */
  54. public int picked;
  55. public int cases26 = cases[0];
  56. public int casesPicked = 0;
  57. public int DealerOffer = 0;
  58. final JLabel lblPickAmount = new JLabel("8");
  59.  
  60.  
  61. private void initialize() {
  62.  
  63. final JButton btnNext = new JButton("Next");
  64. final JButton btnPause2S = new JButton("pause");
  65. final JButton btnButton = new JButton("New button");
  66. final JButton btnNoDeal = new JButton("No Deal");
  67.  
  68.  
  69.  
  70. frame = new JFrame();
  71. frame.setBounds(100, 100, 1450, 890);
  72. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  73. frame.getContentPane().setLayout(null);
  74.  
  75. final JLabel lblBanker = new JLabel("The banker is offering: ");
  76. lblBanker.setFont(new Font("Tahoma", Font.PLAIN, 20));
  77. lblBanker.setBounds(459, 677, 225, 47);
  78. frame.getContentPane().add(lblBanker);
  79. lblBanker.setVisible(false);
  80.  
  81. final JLabel lblBankerOffer = new JLabel(" ");
  82. lblBankerOffer.setFont(new Font("Tahoma", Font.PLAIN, 20));
  83. lblBankerOffer.setBounds(696, 677, 100, 47);
  84. frame.getContentPane().add(lblBankerOffer);
  85. lblBankerOffer.setVisible(false);
  86.  
  87. final JButton btnDeal = new JButton("Deal");
  88. btnDeal.setVisible(false);
  89. btnDeal.setEnabled(false);
  90. btnDeal.addActionListener(new ActionListener() {
  91. public void actionPerformed(ActionEvent e) {
  92. lblBanker.setVisible(false);
  93. lblBankerOffer.setVisible(false);
  94. btnDeal.setVisible(false);
  95. btnNoDeal.setVisible(false);
  96. btnDeal.setEnabled(false);
  97. btnNoDeal.setEnabled(false);
  98.  
  99.  
  100. }
  101. });
  102. btnDeal.setBounds(535, 751, 100, 63);
  103. frame.getContentPane().add(btnDeal);
  104.  
  105. //------------------------No Deal---------------------
  106. btnNoDeal.setVisible(false);
  107. btnNoDeal.setEnabled(false);
  108. btnNoDeal.addActionListener(new ActionListener() {
  109. public void actionPerformed(ActionEvent e) {
  110. lblBanker.setVisible(false);
  111. lblBankerOffer.setVisible(false);
  112. btnDeal.setVisible(false);
  113. btnNoDeal.setVisible(false);
  114. btnDeal.setEnabled(false);
  115. btnNoDeal.setEnabled(false);
  116.  
  117.  
  118. }
  119. });
  120. btnNoDeal.setBounds(785, 751, 100, 63);
  121. frame.getContentPane().add(btnNoDeal);
  122.  
  123. JLabel lblYourCaseLabel = new JLabel("Your case");
  124. lblYourCaseLabel.setFont(new Font("Tahoma", Font.PLAIN, 25));
  125. lblYourCaseLabel.setBounds(136, 708, 119, 47);
  126. frame.getContentPane().add(lblYourCaseLabel);
  127.  
  128. final JLabel lblYourCase = new JLabel("");
  129. lblYourCase.setFont(new Font("Tahoma", Font.PLAIN, 25));
  130. lblYourCase.setBounds(271, 708, 74, 47);
  131. frame.getContentPane().add(lblYourCase);
  132.  
  133. final JLabel lblValue1 = new JLabel("$1");
  134. lblValue1.setHorizontalAlignment(SwingConstants.RIGHT);
  135. lblValue1.setFont(new Font("Tahoma", Font.PLAIN, 20));
  136. lblValue1.setBounds(40, 109, 100, 30);
  137. frame.getContentPane().add(lblValue1);
  138.  
  139. final JLabel lblValue2 = new JLabel("$2");
  140. lblValue2.setHorizontalAlignment(SwingConstants.RIGHT);
  141. lblValue2.setFont(new Font("Tahoma", Font.PLAIN, 20));
  142. lblValue2.setBounds(40, 152, 100, 30);
  143. frame.getContentPane().add(lblValue2);
  144.  
  145. final JLabel lblValue5 = new JLabel("$5");
  146. lblValue5.setHorizontalAlignment(SwingConstants.RIGHT);
  147. lblValue5.setFont(new Font("Tahoma", Font.PLAIN, 20));
  148. lblValue5.setBounds(40, 195, 100, 30);
  149. frame.getContentPane().add(lblValue5);
  150.  
  151. final JLabel lblValue10 = new JLabel("$10");
  152. lblValue10.setHorizontalAlignment(SwingConstants.RIGHT);
  153. lblValue10.setFont(new Font("Tahoma", Font.PLAIN, 20));
  154. lblValue10.setBounds(40, 238, 100, 30);
  155. frame.getContentPane().add(lblValue10);
  156.  
  157. final JLabel lblValue25 = new JLabel("$25");
  158. lblValue25.setHorizontalAlignment(SwingConstants.RIGHT);
  159. lblValue25.setFont(new Font("Tahoma", Font.PLAIN, 20));
  160. lblValue25.setBounds(40, 281, 100, 30);
  161. frame.getContentPane().add(lblValue25);
  162.  
  163. final JLabel lblValue50 = new JLabel("$50");
  164. lblValue50.setHorizontalAlignment(SwingConstants.RIGHT);
  165. lblValue50.setFont(new Font("Tahoma", Font.PLAIN, 20));
  166. lblValue50.setBounds(40, 324, 100, 30);
  167. frame.getContentPane().add(lblValue50);
  168.  
  169. final JLabel lblValue75 = new JLabel("$75");
  170. lblValue75.setHorizontalAlignment(SwingConstants.RIGHT);
  171. lblValue75.setFont(new Font("Tahoma", Font.PLAIN, 20));
  172. lblValue75.setBounds(40, 367, 100, 30);
  173. frame.getContentPane().add(lblValue75);
  174.  
  175. final JLabel lblValue100 = new JLabel("$100");
  176. lblValue100.setHorizontalAlignment(SwingConstants.RIGHT);
  177. lblValue100.setFont(new Font("Tahoma", Font.PLAIN, 20));
  178. lblValue100.setBounds(40, 410, 100, 30);
  179. frame.getContentPane().add(lblValue100);
  180.  
  181. final JLabel lblValue200 = new JLabel("$200");
  182. lblValue200.setHorizontalAlignment(SwingConstants.RIGHT);
  183. lblValue200.setFont(new Font("Tahoma", Font.PLAIN, 20));
  184. lblValue200.setBounds(40, 453, 100, 30);
  185. frame.getContentPane().add(lblValue200);
  186.  
  187. final JLabel lblValue300 = new JLabel("$300");
  188. lblValue300.setHorizontalAlignment(SwingConstants.RIGHT);
  189. lblValue300.setFont(new Font("Tahoma", Font.PLAIN, 20));
  190. lblValue300.setBounds(40, 496, 100, 30);
  191. frame.getContentPane().add(lblValue300);
  192.  
  193. final JLabel lblValue400 = new JLabel("$400");
  194. lblValue400.setHorizontalAlignment(SwingConstants.RIGHT);
  195. lblValue400.setFont(new Font("Tahoma", Font.PLAIN, 20));
  196. lblValue400.setBounds(40, 539, 100, 30);
  197. frame.getContentPane().add(lblValue400);
  198.  
  199. final JLabel lblValue500 = new JLabel("$500");
  200. lblValue500.setHorizontalAlignment(SwingConstants.RIGHT);
  201. lblValue500.setFont(new Font("Tahoma", Font.PLAIN, 20));
  202. lblValue500.setBounds(40, 582, 100, 30);
  203. frame.getContentPane().add(lblValue500);
  204.  
  205. final JLabel lblValue750 = new JLabel("$750");
  206. lblValue750.setHorizontalAlignment(SwingConstants.RIGHT);
  207. lblValue750.setFont(new Font("Tahoma", Font.PLAIN, 20));
  208. lblValue750.setBounds(40, 625, 100, 30);
  209. frame.getContentPane().add(lblValue750);
  210.  
  211. final JLabel lblValue1000 = new JLabel("$1,000");
  212. lblValue1000.setHorizontalAlignment(SwingConstants.RIGHT);
  213. lblValue1000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  214. lblValue1000.setBounds(1280, 109, 100, 30);
  215. frame.getContentPane().add(lblValue1000);
  216.  
  217. final JLabel lblValue5000 = new JLabel("$5,000");
  218. lblValue5000.setHorizontalAlignment(SwingConstants.RIGHT);
  219. lblValue5000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  220. lblValue5000.setBounds(1280, 152, 100, 30);
  221. frame.getContentPane().add(lblValue5000);
  222.  
  223. final JLabel lblValue10000 = new JLabel("$10,000");
  224. lblValue10000.setHorizontalAlignment(SwingConstants.RIGHT);
  225. lblValue10000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  226. lblValue10000.setBounds(1280, 195, 100, 30);
  227. frame.getContentPane().add(lblValue10000);
  228.  
  229. final JLabel lblValue25000 = new JLabel("$25,000");
  230. lblValue25000.setHorizontalAlignment(SwingConstants.RIGHT);
  231. lblValue25000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  232. lblValue25000.setBounds(1280, 238, 100, 30);
  233. frame.getContentPane().add(lblValue25000);
  234.  
  235. final JLabel lblValue50000 = new JLabel("$50,000");
  236. lblValue50000.setHorizontalAlignment(SwingConstants.RIGHT);
  237. lblValue50000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  238. lblValue50000.setBounds(1280, 281, 100, 30);
  239. frame.getContentPane().add(lblValue50000);
  240.  
  241. final JLabel lblValue75000 = new JLabel("$75,000");
  242. lblValue75000.setHorizontalAlignment(SwingConstants.RIGHT);
  243. lblValue75000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  244. lblValue75000.setBounds(1280, 324, 100, 30);
  245. frame.getContentPane().add(lblValue75000);
  246.  
  247. final JLabel lblValue100000 = new JLabel("$100,000");
  248. lblValue100000.setHorizontalAlignment(SwingConstants.RIGHT);
  249. lblValue100000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  250. lblValue100000.setBounds(1280, 367, 100, 30);
  251. frame.getContentPane().add(lblValue100000);
  252.  
  253. final JLabel lblValue200000 = new JLabel("$200,000");
  254. lblValue200000.setHorizontalAlignment(SwingConstants.RIGHT);
  255. lblValue200000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  256. lblValue200000.setBounds(1280, 410, 100, 30);
  257. frame.getContentPane().add(lblValue200000);
  258.  
  259. final JLabel lblValue300000 = new JLabel("$300,000");
  260. lblValue300000.setHorizontalAlignment(SwingConstants.RIGHT);
  261. lblValue300000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  262. lblValue300000.setBounds(1280, 453, 100, 30);
  263. frame.getContentPane().add(lblValue300000);
  264.  
  265. final JLabel lblValue400000 = new JLabel("$400,000");
  266. lblValue400000.setHorizontalAlignment(SwingConstants.RIGHT);
  267. lblValue400000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  268. lblValue400000.setBounds(1280, 496, 100, 30);
  269. frame.getContentPane().add(lblValue400000);
  270.  
  271. final JLabel lblValue500000 = new JLabel("$500,000");
  272. lblValue500000.setHorizontalAlignment(SwingConstants.RIGHT);
  273. lblValue500000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  274. lblValue500000.setBounds(1280, 539, 100, 30);
  275. frame.getContentPane().add(lblValue500000);
  276.  
  277. final JLabel lblValue750000 = new JLabel("$750,000");
  278. lblValue750000.setHorizontalAlignment(SwingConstants.RIGHT);
  279. lblValue750000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  280. lblValue750000.setBounds(1280, 582, 100, 30);
  281. frame.getContentPane().add(lblValue750000);
  282.  
  283. final JLabel lblValue1000000 = new JLabel("$1,000,000");
  284. lblValue1000000.setHorizontalAlignment(SwingConstants.RIGHT);
  285. lblValue1000000.setFont(new Font("Tahoma", Font.PLAIN, 20));
  286. lblValue1000000.setBounds(1280, 625, 100, 30);
  287. frame.getContentPane().add(lblValue1000000);
  288.  
  289. final JButton btn10 = new JButton("10");
  290. btn10.addActionListener(new ActionListener() {
  291. public void actionPerformed(ActionEvent e) {
  292. if (casesPicked==0)
  293. {
  294. btn10.setEnabled(false);
  295. lblYourCase.setText("10");
  296. btn10.setVisible(false);
  297.  
  298. }
  299. else
  300. {
  301. btn10.setText(Integer.toString(cases[10]));
  302. picked = cases[10];
  303. btn10.setEnabled(false);
  304. btnNext.doClick();
  305. }
  306. casesPicked++;
  307. }
  308. });
  309. btn10.setBounds(660, 410, 100, 100);
  310. frame.getContentPane().add(btn10);
  311.  
  312. final JButton btn3 = new JButton("3");
  313. btn3.addActionListener(new ActionListener() {
  314. public void actionPerformed(ActionEvent e) {
  315. if (casesPicked==0)
  316. {
  317. btn3.setEnabled(false);
  318. btn3.setVisible(false);
  319. lblYourCase.setText("3");
  320.  
  321. }
  322. else
  323. {
  324. btn3.setText(Integer.toString(cases[3]));
  325. picked = cases[3];
  326. btn3.setEnabled(false);
  327. btnNext.doClick();
  328. }
  329. casesPicked++;
  330. }
  331. });
  332. btn3.setBounds(598, 539, 100, 100);
  333. frame.getContentPane().add(btn3);
  334.  
  335. final JButton btn2 = new JButton("2");
  336. btn2.addActionListener(new ActionListener() {
  337. public void actionPerformed(ActionEvent e) {
  338. if (casesPicked==0)
  339. {
  340. btn2.setEnabled(false);
  341. btn2.setVisible(false);
  342. lblYourCase.setText("2");
  343.  
  344. }
  345. else
  346. {
  347. btn2.setText(Integer.toString(cases[2]));
  348. picked = cases[2];
  349. btn2.setEnabled(false);
  350. btnNext.doClick();
  351. }
  352. casesPicked++;
  353. }
  354. });
  355. btn2.setBounds(473, 539, 100, 100);
  356. frame.getContentPane().add(btn2);
  357.  
  358. final JButton btn9 = new JButton("9");
  359. btn9.addActionListener(new ActionListener() {
  360. public void actionPerformed(ActionEvent e) {
  361. if (casesPicked==0)
  362. {
  363. btn9.setEnabled(false);
  364. btn9.setVisible(false);
  365. lblYourCase.setText("9");
  366.  
  367. }
  368. else
  369. {
  370. btn9.setText(Integer.toString(cases[9]));
  371. picked = cases[9];
  372. btn9.setEnabled(false);
  373. btnNext.doClick();
  374. }
  375. casesPicked++;
  376. }
  377. });
  378. btn9.setBounds(535, 410, 100, 100);
  379. frame.getContentPane().add(btn9);
  380.  
  381. final JButton btn8 = new JButton("8");
  382. btn8.addActionListener(new ActionListener() {
  383. public void actionPerformed(ActionEvent e) {
  384. if (casesPicked==0)
  385. {
  386. btn8.setEnabled(false);
  387. btn8.setVisible(false);
  388. lblYourCase.setText("8");
  389.  
  390. }
  391. else
  392. {
  393. btn8.setText(Integer.toString(cases[8]));
  394. picked = cases[8];
  395. btn8.setEnabled(false);
  396. btnNext.doClick();
  397. }
  398. casesPicked++;
  399. }
  400. });
  401. btn8.setBounds(410, 410, 100, 100);
  402. frame.getContentPane().add(btn8);
  403.  
  404. final JButton btn7 = new JButton("7");
  405. btn7.addActionListener(new ActionListener() {
  406. public void actionPerformed(ActionEvent e) {
  407. if (casesPicked==0)
  408. {
  409. btn7.setEnabled(false);
  410. btn7.setVisible(false);
  411. lblYourCase.setText("7");
  412.  
  413. }
  414. else
  415. {
  416. btn7.setText(Integer.toString(cases[7]));
  417. picked = cases[7];
  418. btn7.setEnabled(false);
  419. btnNext.doClick();
  420. }
  421. casesPicked++;
  422.  
  423. }
  424. });
  425. btn7.setBounds(285, 410, 100, 100);
  426. frame.getContentPane().add(btn7);
  427.  
  428. final JButton btn11 = new JButton("11");
  429. btn11.addActionListener(new ActionListener() {
  430. public void actionPerformed(ActionEvent e) {
  431. if (casesPicked==0)
  432. {
  433. btn11.setEnabled(false);
  434. btn11.setVisible(false);
  435. lblYourCase.setText("11");
  436.  
  437. }
  438. else
  439. {
  440. btn11.setText(Integer.toString(cases[11]));
  441. picked = cases[11];
  442. btn11.setEnabled(false);
  443. btnNext.doClick();
  444. }
  445. casesPicked++;
  446. }
  447. });
  448. btn11.setBounds(785, 410, 100, 100);
  449. frame.getContentPane().add(btn11);
  450.  
  451. final JButton btn12 = new JButton("12");
  452. btn12.addActionListener(new ActionListener() {
  453. public void actionPerformed(ActionEvent e) {
  454. if (casesPicked==0)
  455. {
  456. btn12.setEnabled(false);
  457. btn12.setVisible(false);
  458. lblYourCase.setText("12");
  459.  
  460. }
  461. else
  462. {
  463. btn12.setText(Integer.toString(cases[12]));
  464. picked = cases[12];
  465. btn12.setEnabled(false);
  466. btnNext.doClick();
  467. }
  468. casesPicked++;
  469. }
  470. });
  471. btn12.setBounds(910, 410, 100, 100);
  472. frame.getContentPane().add(btn12);
  473.  
  474. final JButton btn13 = new JButton("13");
  475. btn13.addActionListener(new ActionListener() {
  476. public void actionPerformed(ActionEvent e) {
  477. if (casesPicked==0)
  478. {
  479. btn13.setEnabled(false);
  480. btn13.setVisible(false);
  481. lblYourCase.setText("13");
  482.  
  483. }
  484. else
  485. {
  486. btn13.setText(Integer.toString(cases[13]));
  487. picked = cases[13];
  488. btn13.setEnabled(false);
  489. btnNext.doClick();
  490. }
  491. casesPicked++;
  492. }
  493. });
  494. btn13.setBounds(1035, 410, 100, 100);
  495. frame.getContentPane().add(btn13);
  496.  
  497. final JButton btn4 = new JButton("4");
  498. btn4.addActionListener(new ActionListener() {
  499. public void actionPerformed(ActionEvent e) {
  500. if (casesPicked==0)
  501. {
  502. btn4.setEnabled(false);
  503. btn4.setVisible(false);
  504. lblYourCase.setText("4");
  505.  
  506. }
  507. else
  508. {
  509. btn4.setText(Integer.toString(cases[4]));
  510. picked = cases[4];
  511. btn4.setEnabled(false);
  512. btnNext.doClick();
  513. }
  514. casesPicked++;
  515. }
  516. });
  517. btn4.setBounds(722, 539, 100, 100);
  518. frame.getContentPane().add(btn4);
  519.  
  520. final JButton btn5 = new JButton("5");
  521. btn5.addActionListener(new ActionListener() {
  522. public void actionPerformed(ActionEvent e) {
  523. if (casesPicked==0)
  524. {
  525. btn5.setEnabled(false);
  526. btn5.setVisible(false);
  527. lblYourCase.setText("5");
  528.  
  529. }
  530. else
  531. {
  532. btn5.setText(Integer.toString(cases[5]));
  533. picked = cases[5];
  534. btn5.setEnabled(false);
  535. btnNext.doClick();
  536. }
  537. casesPicked++;
  538. }
  539. });
  540. btn5.setBounds(847, 539, 100, 100);
  541. frame.getContentPane().add(btn5);
  542.  
  543. final JButton btn6 = new JButton("6");
  544. btn6.addActionListener(new ActionListener() {
  545. public void actionPerformed(ActionEvent e) {
  546. if (casesPicked==0)
  547. {
  548. btn6.setEnabled(false);
  549. btn6.setVisible(false);
  550. lblYourCase.setText("6");
  551.  
  552. }
  553. else
  554. {
  555. btn6.setText(Integer.toString(cases[6]));
  556. picked = cases[6];
  557. btn6.setEnabled(false);
  558. btnNext.doClick();
  559. }
  560. casesPicked++;
  561. }
  562. });
  563. btn6.setBounds(972, 539, 100, 100);
  564. frame.getContentPane().add(btn6);
  565.  
  566. final JButton btn1 = new JButton("1");
  567. btn1.addActionListener(new ActionListener() {
  568. public void actionPerformed(ActionEvent arg0) {
  569. if (casesPicked==0)
  570. {
  571. btn1.setEnabled(false);
  572. btn1.setVisible(false);
  573. lblYourCase.setText("1");
  574.  
  575. }
  576. else
  577. {
  578. btn1.setText(Integer.toString(cases[1]));
  579. picked = cases[1];
  580. btn1.setEnabled(false);
  581. btnNext.doClick();
  582. }
  583. casesPicked++;
  584. }
  585. });
  586. btn1.setBounds(348, 539, 100, 100);
  587. frame.getContentPane().add(btn1);
  588.  
  589. final JButton btn14 = new JButton("14");
  590. btn14.addActionListener(new ActionListener() {
  591. public void actionPerformed(ActionEvent e) {
  592. if (casesPicked==0)
  593. {
  594. btn14.setEnabled(false);
  595. btn14.setVisible(false);
  596. lblYourCase.setText("14");
  597.  
  598. }
  599. else
  600. {
  601. btn14.setText(Integer.toString(cases[14]));
  602. picked = cases[14];
  603. btn14.setEnabled(false);
  604. btnNext.doClick();
  605. }
  606. casesPicked++;
  607. }
  608. });
  609. btn14.setBounds(285, 287, 100, 100);
  610. frame.getContentPane().add(btn14);
  611.  
  612. final JButton btn21 = new JButton("21");
  613. btn21.addActionListener(new ActionListener() {
  614. public void actionPerformed(ActionEvent e) {
  615. if (casesPicked==0)
  616. {
  617. btn21.setEnabled(false);
  618. btn21.setVisible(false);
  619. lblYourCase.setText("21");
  620.  
  621. }
  622. else
  623. {
  624. btn21.setText(Integer.toString(cases[21]));
  625. picked = cases[21];
  626. btn21.setEnabled(false);
  627. btnNext.doClick();
  628. }
  629. casesPicked++;
  630. }
  631. });
  632. btn21.setBounds(348, 163, 100, 100);
  633. frame.getContentPane().add(btn21);
  634.  
  635. final JButton btn15 = new JButton("15");
  636. btn15.addActionListener(new ActionListener() {
  637. public void actionPerformed(ActionEvent e) {
  638. if (casesPicked==0)
  639. {
  640. btn15.setEnabled(false);
  641. btn15.setVisible(false);
  642. lblYourCase.setText("15");
  643.  
  644. }
  645. else
  646. {
  647. btn15.setText(Integer.toString(cases[15]));
  648. picked = cases[15];
  649. btn15.setEnabled(false);
  650. btnNext.doClick();
  651. }
  652. casesPicked++;
  653. }
  654. });
  655. btn15.setBounds(410, 281, 100, 100);
  656. frame.getContentPane().add(btn15);
  657.  
  658. final JButton btn16 = new JButton("16");
  659. btn16.addActionListener(new ActionListener() {
  660. public void actionPerformed(ActionEvent e) {
  661. if (casesPicked==0)
  662. {
  663. btn16.setEnabled(false);
  664. btn16.setVisible(false);
  665. lblYourCase.setText("16");
  666.  
  667. }
  668. else
  669. {
  670. btn16.setText(Integer.toString(cases[16]));
  671. picked = cases[16];
  672. btn16.setEnabled(false);
  673. btnNext.doClick();
  674. }
  675. casesPicked++;
  676. }
  677. });
  678. btn16.setBounds(535, 281, 100, 100);
  679. frame.getContentPane().add(btn16);
  680.  
  681. final JButton btn17 = new JButton("17");
  682. btn17.addActionListener(new ActionListener() {
  683. public void actionPerformed(ActionEvent e) {
  684. if (casesPicked==0)
  685. {
  686. btn17.setEnabled(false);
  687. btn17.setVisible(false);
  688. lblYourCase.setText("17");
  689.  
  690. }
  691. else
  692. {
  693. btn17.setText(Integer.toString(cases[17]));
  694. picked = cases[17];
  695. btn17.setEnabled(false);
  696. btnNext.doClick();
  697. }
  698. casesPicked++;
  699. }
  700. });
  701. btn17.setBounds(660, 281, 100, 100);
  702. frame.getContentPane().add(btn17);
  703.  
  704. final JButton btn18 = new JButton("18");
  705. btn18.addActionListener(new ActionListener() {
  706. public void actionPerformed(ActionEvent e) {
  707. if (casesPicked==0)
  708. {
  709. btn18.setEnabled(false);
  710. btn18.setVisible(false);
  711. lblYourCase.setText("18");
  712.  
  713. }
  714. else
  715. {
  716. btn18.setText(Integer.toString(cases[18]));
  717. picked = cases[18];
  718. btn18.setEnabled(false);
  719. btnNext.doClick();
  720. }
  721. casesPicked++;
  722. }
  723. });
  724. btn18.setBounds(785, 281, 100, 100);
  725. frame.getContentPane().add(btn18);
  726.  
  727. final JButton btn19 = new JButton("19");
  728. btn19.addActionListener(new ActionListener() {
  729. public void actionPerformed(ActionEvent e) {
  730. if (casesPicked==0)
  731. {
  732. btn19.setEnabled(false);
  733. btn19.setVisible(false);
  734. lblYourCase.setText("19");
  735.  
  736. }
  737. else
  738. {
  739. btn19.setText(Integer.toString(cases[19]));
  740. picked = cases[19];
  741. btn19.setEnabled(false);
  742. btnNext.doClick();
  743. }
  744. casesPicked++;
  745. }
  746. });
  747. btn19.setBounds(910, 281, 100, 100);
  748. frame.getContentPane().add(btn19);
  749.  
  750. final JButton btn20 = new JButton("20");
  751. btn20.addActionListener(new ActionListener() {
  752. public void actionPerformed(ActionEvent e) {
  753. if (casesPicked==0)
  754. {
  755. btn20.setEnabled(false);
  756. btn20.setVisible(false);
  757. lblYourCase.setText("20");
  758.  
  759. }
  760. else
  761. {
  762. btn20.setText(Integer.toString(cases[20]));
  763. picked = cases[20];
  764. btn20.setEnabled(false);
  765. btnNext.doClick();
  766. }
  767. casesPicked++;
  768. }
  769. });
  770. btn20.setBounds(1035, 281, 100, 100);
  771. frame.getContentPane().add(btn20);
  772.  
  773. final JButton btn22 = new JButton("22");
  774. btn22.addActionListener(new ActionListener() {
  775. public void actionPerformed(ActionEvent e) {
  776. if (casesPicked==0)
  777. {
  778. btn22.setEnabled(false);
  779. btn22.setVisible(false);
  780. lblYourCase.setText("22");
  781.  
  782. }
  783. else
  784. {
  785. btn22.setText(Integer.toString(cases[22]));
  786. picked = cases[22];
  787. btn22.setEnabled(false);
  788. btnNext.doClick();
  789. }
  790. casesPicked++;
  791. }
  792. });
  793. btn22.setBounds(473, 163, 100, 100);
  794. frame.getContentPane().add(btn22);
  795.  
  796. final JButton btn23 = new JButton("23");
  797. btn23.addActionListener(new ActionListener() {
  798. public void actionPerformed(ActionEvent e) {
  799. if (casesPicked==0)
  800. {
  801. btn23.setEnabled(false);
  802. btn23.setVisible(false);
  803. lblYourCase.setText("23");
  804.  
  805. }
  806. else
  807. {
  808. btn23.setText(Integer.toString(cases[23]));
  809. picked = cases[23];
  810. btn23.setEnabled(false);
  811. btnNext.doClick();
  812. }
  813. casesPicked++;
  814. }
  815. });
  816. btn23.setBounds(598, 163, 100, 100);
  817. frame.getContentPane().add(btn23);
  818.  
  819. final JButton btn24 = new JButton("24");
  820. btn24.addActionListener(new ActionListener() {
  821. public void actionPerformed(ActionEvent e) {
  822. if (casesPicked==0)
  823. {
  824. btn24.setEnabled(false);
  825. btn24.setVisible(false);
  826. lblYourCase.setText("24");
  827.  
  828. }
  829. else
  830. {
  831. btn24.setText(Integer.toString(cases[24]));
  832. picked = cases[24];
  833. btn24.setEnabled(false);
  834. btnNext.doClick();
  835. }
  836. casesPicked++;
  837. }
  838. });
  839. btn24.setBounds(722, 163, 100, 100);
  840. frame.getContentPane().add(btn24);
  841.  
  842. final JButton btn25 = new JButton("25");
  843. btn25.addActionListener(new ActionListener() {
  844. public void actionPerformed(ActionEvent e) {
  845. if (casesPicked==0)
  846. {
  847. btn25.setEnabled(false);
  848. btn25.setVisible(false);
  849. lblYourCase.setText("25");
  850.  
  851. }
  852. else
  853. {
  854. btn25.setText(Integer.toString(cases[25]));
  855. picked = cases[25];
  856. btn25.setEnabled(false);
  857. btnNext.doClick();
  858. }
  859. casesPicked++;
  860. }
  861. });
  862. btn25.setBounds(847, 163, 100, 100);
  863. frame.getContentPane().add(btn25);
  864.  
  865. final JButton btn26 = new JButton("26");
  866. btn26.addActionListener(new ActionListener() {
  867. public void actionPerformed(ActionEvent e) {
  868. if (casesPicked==0)
  869. {
  870. btn26.setEnabled(false);
  871. btn26.setVisible(false);
  872. lblYourCase.setText("26");
  873.  
  874. }
  875. else
  876. {
  877. btn20.setText(Integer.toString(cases26));
  878. picked = cases26;
  879. btn26.setEnabled(false);
  880. btnNext.doClick();
  881. }
  882. casesPicked++;
  883. }
  884. });
  885. btn26.setBounds(972, 163, 100, 100);
  886. frame.getContentPane().add(btn26);
  887.  
  888. JLabel lblTitle = new JLabel("DEAL OR NO DEAL");
  889. lblTitle.setFont(new Font("Copperplate Gothic Bold", Font.PLAIN, 35));
  890. lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
  891. lblTitle.setBounds(348, 13, 724, 70);
  892. frame.getContentPane().add(lblTitle);
  893.  
  894. //-----------------Button Next-----------------
  895. btnNext.addActionListener(new ActionListener() {
  896. public void actionPerformed(ActionEvent e) {
  897.  
  898. if (picked==1)
  899. {
  900. lblValue1.setForeground(Color.red);
  901. }
  902. else if (picked==2)
  903. {
  904. lblValue2.setForeground(Color.red);
  905. }
  906. else if (picked==5)
  907. {
  908. lblValue5.setForeground(Color.red);
  909. }
  910. else if (picked==10)
  911. {
  912. lblValue10.setForeground(Color.red);
  913. }
  914. else if (picked==25)
  915. {
  916. lblValue25.setForeground(Color.red);
  917. }
  918. else if (picked==50)
  919. {
  920. lblValue50.setForeground(Color.red);
  921. }
  922. else if (picked==75)
  923. {
  924. lblValue75.setForeground(Color.red);
  925. }
  926. else if (picked==100)
  927. {
  928. lblValue100.setForeground(Color.red);
  929. }
  930. else if (picked==200)
  931. {
  932. lblValue200.setForeground(Color.red);
  933. }
  934. else if (picked==300)
  935. {
  936. lblValue300.setForeground(Color.red);
  937. }
  938. else if (picked==400)
  939. {
  940. lblValue400.setForeground(Color.red);
  941. }
  942. else if (picked==500)
  943. {
  944. lblValue500.setForeground(Color.red);
  945. }
  946. else if (picked==750)
  947. {
  948. lblValue750.setForeground(Color.red);
  949. }
  950. else if (picked==1000)
  951. {
  952. lblValue1000.setForeground(Color.red);
  953. }
  954. else if (picked==5000)
  955. {
  956. lblValue5000.setForeground(Color.red);
  957. }
  958. else if (picked==10000)
  959. {
  960. lblValue10000.setForeground(Color.red);
  961. }
  962. else if (picked==25000)
  963. {
  964. lblValue25000.setForeground(Color.red);
  965. }
  966. else if (picked==50000)
  967. {
  968. lblValue50000.setForeground(Color.red);
  969. }
  970. else if (picked==75000)
  971. {
  972. lblValue75000.setForeground(Color.red);
  973. }
  974. else if (picked==100000)
  975. {
  976. lblValue100000.setForeground(Color.red);
  977. }
  978. else if (picked==200000)
  979. {
  980. lblValue200000.setForeground(Color.red);
  981. }
  982. else if (picked==300000)
  983. {
  984. lblValue300000.setForeground(Color.red);
  985. }
  986. else if (picked==400000)
  987. {
  988. lblValue400000.setForeground(Color.red);
  989. }
  990. else if (picked==500000)
  991. {
  992. lblValue500000.setForeground(Color.red);
  993. }
  994. else if (picked==750000)
  995. {
  996. lblValue750000.setForeground(Color.red);
  997. }
  998. else if (picked==1000000)
  999. {
  1000. lblValue1000000.setForeground(Color.red);
  1001. }
  1002. else
  1003. {
  1004. lblValue1000000.setForeground(Color.green);
  1005. }
  1006.  
  1007. btnButton.doClick();
  1008.  
  1009.  
  1010.  
  1011. }
  1012. });
  1013. btnNext.setBounds(1363, 784, 57, 30);
  1014. frame.getContentPane().add(btnNext);
  1015.  
  1016. //-----------Pause 2 Seconds-------------------------------------------
  1017. btnPause2S.setVisible(false);
  1018. btnPause2S.addActionListener(new ActionListener() {
  1019. public void actionPerformed(ActionEvent e) {
  1020. try {
  1021. Thread.sleep(2000); //1000 milliseconds is one second.
  1022. } catch(InterruptedException ex) {
  1023. Thread.currentThread().interrupt();
  1024. }
  1025.  
  1026. }
  1027. });
  1028. btnPause2S.setBounds(1400, 746, 20, 25);
  1029. frame.getContentPane().add(btnPause2S);
  1030.  
  1031. //--------------------Do button--------------------
  1032. btnButton.setVisible(false);
  1033. btnButton.addActionListener(new ActionListener() {
  1034. public void actionPerformed(ActionEvent e) {
  1035. if (casesPicked==8)
  1036. {
  1037. lblBanker.setVisible(true);
  1038. lblBankerOffer.setVisible(true);
  1039. btnDeal.setVisible(true);
  1040. btnNoDeal.setVisible(true);
  1041. btnDeal.setEnabled(true);
  1042. btnNoDeal.setEnabled(true);
  1043. lblBankerOffer.setText("$300");
  1044.  
  1045. }
  1046. else if (casesPicked==14)
  1047. {
  1048. lblBanker.setVisible(true);
  1049. lblBankerOffer.setVisible(true);
  1050. btnDeal.setVisible(true);
  1051. btnNoDeal.setVisible(true);
  1052. btnDeal.setEnabled(true);
  1053. btnNoDeal.setEnabled(true);
  1054. lblBankerOffer.setText("$300");
  1055. }
  1056. else if (casesPicked==18)
  1057. {
  1058. lblBanker.setVisible(true);
  1059. lblBankerOffer.setVisible(true);
  1060. btnDeal.setVisible(true);
  1061. btnNoDeal.setVisible(true);
  1062. btnDeal.setEnabled(true);
  1063. btnNoDeal.setEnabled(true);
  1064. lblBankerOffer.setText("$300");
  1065. }
  1066. else if (casesPicked==21)
  1067. {
  1068. lblBanker.setVisible(true);
  1069. lblBankerOffer.setVisible(true);
  1070. btnDeal.setVisible(true);
  1071. btnNoDeal.setVisible(true);
  1072. btnDeal.setEnabled(true);
  1073. btnNoDeal.setEnabled(true);
  1074. lblBankerOffer.setText("$300");
  1075. }
  1076. else if (casesPicked==23)
  1077. {
  1078. lblBanker.setVisible(true);
  1079. lblBankerOffer.setVisible(true);
  1080. btnDeal.setVisible(true);
  1081. btnNoDeal.setVisible(true);
  1082. btnDeal.setEnabled(true);
  1083. btnNoDeal.setEnabled(true);
  1084. lblBankerOffer.setText("$300");
  1085. }
  1086. else if (casesPicked==24)
  1087. {
  1088. lblBanker.setVisible(true);
  1089. lblBankerOffer.setVisible(true);
  1090. btnDeal.setVisible(true);
  1091. btnNoDeal.setVisible(true);
  1092. btnDeal.setEnabled(true);
  1093. btnNoDeal.setEnabled(true);
  1094. lblBankerOffer.setText("$300");
  1095. }
  1096. else if (casesPicked==25)
  1097. {
  1098. lblBanker.setVisible(true);
  1099. lblBankerOffer.setVisible(true);
  1100. btnDeal.setVisible(true);
  1101. btnNoDeal.setVisible(true);
  1102. btnDeal.setEnabled(true);
  1103. btnNoDeal.setEnabled(true);
  1104. lblBankerOffer.setText("$300");
  1105. }
  1106. else if (casesPicked==26)
  1107. {
  1108. lblBanker.setVisible(true);
  1109. lblBankerOffer.setVisible(true);
  1110. btnDeal.setVisible(true);
  1111. btnNoDeal.setVisible(true);
  1112. btnDeal.setEnabled(true);
  1113. btnNoDeal.setEnabled(true);
  1114. lblBankerOffer.setText("$300");
  1115. }
  1116. else
  1117. {
  1118.  
  1119. }
  1120.  
  1121. }
  1122. });
  1123. btnButton.setBounds(1297, 746, 97, 25);
  1124. frame.getContentPane().add(btnButton);
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131. btnNext.setVisible(false);
  1132.  
  1133.  
  1134.  
  1135. }
  1136.  
  1137.  
  1138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement