Advertisement
Guest User

Program

a guest
Apr 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.22 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JLabel;
  5. import javax.swing.JOptionPane;
  6. import javax.swing.JPanel;
  7. import javax.swing.border.EmptyBorder;
  8. import javax.swing.border.LineBorder;
  9. import java.awt.Color;
  10. import java.awt.Font;
  11. import java.awt.event.ActionEvent;
  12. import java.awt.event.ActionListener;
  13.  
  14. import javax.swing.SwingConstants;
  15. import javax.swing.JTextField;
  16. import javax.swing.JButton;
  17. import javax.swing.JPasswordField;
  18.  
  19. public class DuasOrdering {
  20.  
  21. private JFrame frame;
  22. private JTextField txtUsername;
  23. private JPasswordField txtPassword;
  24. private JTextField txtDisplay;
  25.  
  26. String operations;
  27. String answer;
  28. double firstnum;
  29. double secondnum;
  30. double result;
  31. private JTextField textReceipt;
  32. private JTextField textTax;
  33. private JTextField textSubtotal;
  34. private JTextField textTotal;
  35. private JTextField textFriedEggRollsQty;
  36. private JTextField textSpringRollsQty;
  37. private JTextField textHousePhoQty;
  38. private JTextField textShrimpPhoQty;
  39. private JTextField textChickenPhoQty;
  40. private JTextField textBeefPhoQty;
  41. private JTextField textPorkMixaoQty;
  42. private JTextField textChickenMixaoQty;
  43. private JTextField textTofuMixaoQty;
  44. private JTextField textShrimpMixaoQty;
  45. private JTextField textSteakSaladQty;
  46. private JTextField textChickenSaladQty;
  47. private JTextField textLemongrassTofuSaladQty;
  48. private JTextField textShrimpSaladQty;
  49. private JTextField textWaterQty;
  50. private JTextField textCokeQty;
  51. private JTextField textTeaQty;
  52.  
  53. double friedeggrolls = 3.25;
  54. double springrolls = 3.75;
  55. double housepho = 8.95;
  56. double shrimppho = 10.95;
  57. double chickenpho = 8.95;
  58. double beefpho = 8.95;
  59. double porkmixao = 8.95;
  60. double chickenmixao = 8.95;
  61. double tofumixao = 8.00;
  62. double shrimpmixao = 10.75;
  63. double steaksalad = 10.75;
  64. double chickensalad = 8.95;
  65. double lemongrasstofusalad = 8.00;
  66. double shrimpsalad = 10.75;
  67. double water = .75;
  68. double coke = 1.75;
  69. double tea = 2.75;
  70. double tax = 7.0;
  71.  
  72.  
  73. /**
  74. * Launch the application.
  75. */
  76. public static void main(String[] args) {
  77. EventQueue.invokeLater(new Runnable() {
  78. public void run() {
  79. try {
  80. DuasOrdering window = new DuasOrdering();
  81. window.frame.setVisible(true);
  82. } catch (Exception e) {
  83. e.printStackTrace();
  84. }
  85. }
  86. });
  87. }
  88.  
  89. /**
  90. * Create the application.
  91. */
  92. public DuasOrdering() {
  93. initialize();
  94. }
  95.  
  96.  
  97.  
  98. /**
  99. * Initialize the contents of the frame.
  100. */
  101. private void initialize() {
  102. frame = new JFrame();
  103. frame.setBounds(0, 100, 900, 650);
  104. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  105. frame.getContentPane().setLayout(null);
  106.  
  107. JPanel panel_menu = new JPanel();
  108. panel_menu.setBorder(new LineBorder(new Color(128, 0, 0), 6, true));
  109. panel_menu.setBounds(10, 11, 337, 589);
  110. frame.getContentPane().add(panel_menu);
  111. panel_menu.setLayout(null);
  112.  
  113.  
  114.  
  115. /*
  116. * ------DUA VIETNAMESE NOODLE SOUP--------
  117. */
  118. JLabel Dua1 = new JLabel("Dua");
  119. Dua1.setBounds(357, 21, 229, 123);
  120. frame.getContentPane().add(Dua1);
  121. Dua1.setForeground(new Color(0, 0, 0));
  122. Dua1.setHorizontalAlignment(SwingConstants.CENTER);
  123. Dua1.setFont(new Font("Tempus Sans ITC", Font.BOLD, 86));
  124.  
  125. JLabel Dua2 = new JLabel("Dua");
  126. Dua2.setHorizontalAlignment(SwingConstants.CENTER);
  127. Dua2.setForeground(new Color(128, 0, 0));
  128. Dua2.setFont(new Font("Tempus Sans ITC", Font.BOLD, 86));
  129. Dua2.setBounds(367, 11, 219, 142);
  130. frame.getContentPane().add(Dua2);
  131.  
  132. JLabel lblVietnameseNoodleSoup = new JLabel("Vietnamese Noodle Soup");
  133. lblVietnameseNoodleSoup.setFont(new Font("Tempus Sans ITC", Font.PLAIN, 18));
  134. lblVietnameseNoodleSoup.setForeground(new Color(128, 0, 0));
  135. lblVietnameseNoodleSoup.setBounds(379, 131, 193, 14);
  136. frame.getContentPane().add(lblVietnameseNoodleSoup);
  137.  
  138.  
  139.  
  140.  
  141. /*
  142. * ------MENU HEADERS--------
  143. */
  144. JLabel lblMenu = new JLabel("Menu");
  145. lblMenu.setBounds(123, 11, 96, 42);
  146. lblMenu.setFont(new Font("Tempus Sans ITC", Font.BOLD, 36));
  147. panel_menu.add(lblMenu);
  148.  
  149. JLabel lblAppetizers = new JLabel("Appetizers");
  150. lblAppetizers.setFont(new Font("Tempus Sans ITC", Font.BOLD, 18));
  151. lblAppetizers.setBounds(23, 54, 89, 22);
  152. panel_menu.add(lblAppetizers);
  153.  
  154. JLabel lblPho = new JLabel("Pho");
  155. lblPho.setFont(new Font("Tempus Sans ITC", Font.BOLD, 18));
  156. lblPho.setBounds(23, 124, 42, 22);
  157. panel_menu.add(lblPho);
  158.  
  159. JLabel lblMixao = new JLabel("Mixao");
  160. lblMixao.setFont(new Font("Tempus Sans ITC", Font.BOLD, 18));
  161. lblMixao.setBounds(23, 229, 53, 22);
  162. panel_menu.add(lblMixao);
  163.  
  164. JLabel lblSalads = new JLabel("Salads");
  165. lblSalads.setFont(new Font("Tempus Sans ITC", Font.BOLD, 18));
  166. lblSalads.setBounds(23, 337, 53, 22);
  167. panel_menu.add(lblSalads);
  168.  
  169. JLabel lblDrinks = new JLabel("Drinks");
  170. lblDrinks.setFont(new Font("Tempus Sans ITC", Font.BOLD, 18));
  171. lblDrinks.setBounds(23, 445, 67, 22);
  172. panel_menu.add(lblDrinks);
  173.  
  174. JLabel lblQty = new JLabel("Qty.");
  175. lblQty.setFont(new Font("Tempus Sans ITC", Font.BOLD, 18));
  176. lblQty.setBounds(280, 54, 47, 22);
  177. panel_menu.add(lblQty);
  178.  
  179.  
  180. /*
  181. * ------APPETIZERS--------
  182. */
  183. JLabel lblFriedEggrolls = new JLabel("Fried Eggrolls (2)");
  184. lblFriedEggrolls.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  185. lblFriedEggrolls.setForeground(new Color(128, 0, 0));
  186. lblFriedEggrolls.setBounds(44, 81, 120, 14);
  187. panel_menu.add(lblFriedEggrolls);
  188.  
  189. JLabel label_FriedEggRollsPrice = new JLabel("$3.25");
  190. label_FriedEggRollsPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  191. label_FriedEggRollsPrice.setBounds(209, 81, 42, 14);
  192. panel_menu.add(label_FriedEggRollsPrice);
  193.  
  194. JLabel lblSpringRolls = new JLabel("Spring Rolls (2)");
  195. lblSpringRolls.setForeground(new Color(128, 0, 0));
  196. lblSpringRolls.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  197. lblSpringRolls.setBounds(44, 99, 120, 14);
  198. panel_menu.add(lblSpringRolls);
  199.  
  200. JLabel label_SpringRollsPrice = new JLabel("$3.75");
  201. label_SpringRollsPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  202. label_SpringRollsPrice.setBounds(209, 98, 42, 14);
  203. panel_menu.add(label_SpringRollsPrice);
  204.  
  205.  
  206. /*
  207. * ------PHO--------
  208. */
  209. JLabel lblChickenPho = new JLabel("Chicken Pho");
  210. lblChickenPho.setForeground(new Color(128, 0, 0));
  211. lblChickenPho.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  212. lblChickenPho.setBounds(44, 186, 120, 22);
  213. panel_menu.add(lblChickenPho);
  214.  
  215. JLabel label_ChickenPhoPrice = new JLabel("$8.95");
  216. label_ChickenPhoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  217. label_ChickenPhoPrice.setBounds(209, 190, 42, 14);
  218. panel_menu.add(label_ChickenPhoPrice);
  219.  
  220. JLabel lblShrimpPho = new JLabel("Shrimp Pho");
  221. lblShrimpPho.setForeground(new Color(128, 0, 0));
  222. lblShrimpPho.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  223. lblShrimpPho.setBounds(44, 165, 120, 22);
  224. panel_menu.add(lblShrimpPho);
  225.  
  226. JLabel label_ShrimpPhoPrice = new JLabel("$10.95");
  227. label_ShrimpPhoPrice.setHorizontalAlignment(SwingConstants.CENTER);
  228. label_ShrimpPhoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  229. label_ShrimpPhoPrice.setBounds(198, 169, 53, 14);
  230. panel_menu.add(label_ShrimpPhoPrice);
  231.  
  232. JLabel lblHousePho = new JLabel("House Pho");
  233. lblHousePho.setForeground(new Color(128, 0, 0));
  234. lblHousePho.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  235. lblHousePho.setBounds(44, 144, 120, 22);
  236. panel_menu.add(lblHousePho);
  237.  
  238. JLabel label_HousePhoPrice = new JLabel("$8.95");
  239. label_HousePhoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  240. label_HousePhoPrice.setBounds(209, 148, 42, 14);
  241. panel_menu.add(label_HousePhoPrice);
  242.  
  243. JLabel lblBeefPho = new JLabel("Beef Pho");
  244. lblBeefPho.setForeground(new Color(128, 0, 0));
  245. lblBeefPho.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  246. lblBeefPho.setBounds(44, 206, 120, 22);
  247. panel_menu.add(lblBeefPho);
  248.  
  249. JLabel label_BeefPhoPrice = new JLabel("$8.95");
  250. label_BeefPhoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  251. label_BeefPhoPrice.setBounds(209, 210, 42, 14);
  252. panel_menu.add(label_BeefPhoPrice);
  253.  
  254.  
  255. /*
  256. * ------MIXAO--------
  257. */
  258. JLabel lblPorkMixao = new JLabel("Pork Mixao");
  259. lblPorkMixao.setForeground(new Color(128, 0, 0));
  260. lblPorkMixao.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  261. lblPorkMixao.setBounds(44, 251, 120, 22);
  262. panel_menu.add(lblPorkMixao);
  263.  
  264. JLabel label_PorkMixaoPrice = new JLabel("$8.95");
  265. label_PorkMixaoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  266. label_PorkMixaoPrice.setBounds(209, 254, 42, 14);
  267. panel_menu.add(label_PorkMixaoPrice);
  268.  
  269. JLabel lblChickenMixao = new JLabel("Chicken Mixao");
  270. lblChickenMixao.setForeground(new Color(128, 0, 0));
  271. lblChickenMixao.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  272. lblChickenMixao.setBounds(44, 273, 120, 22);
  273. panel_menu.add(lblChickenMixao);
  274.  
  275. JLabel label_ChickenMixaoPrice = new JLabel("$8.95");
  276. label_ChickenMixaoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  277. label_ChickenMixaoPrice.setBounds(209, 277, 42, 14);
  278. panel_menu.add(label_ChickenMixaoPrice);
  279.  
  280. JLabel lblTofuMixao = new JLabel("Tofu Mixao");
  281. lblTofuMixao.setForeground(new Color(128, 0, 0));
  282. lblTofuMixao.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  283. lblTofuMixao.setBounds(44, 293, 120, 22);
  284. panel_menu.add(lblTofuMixao);
  285.  
  286. JLabel label_TofuMixaoPrice = new JLabel("$8.00");
  287. label_TofuMixaoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  288. label_TofuMixaoPrice.setBounds(209, 297, 42, 14);
  289. panel_menu.add(label_TofuMixaoPrice);
  290.  
  291. JLabel lblShrimpMixao = new JLabel("Shrimp Mixao");
  292. lblShrimpMixao.setForeground(new Color(128, 0, 0));
  293. lblShrimpMixao.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  294. lblShrimpMixao.setBounds(44, 314, 120, 22);
  295. panel_menu.add(lblShrimpMixao);
  296.  
  297. JLabel label_ShrimpMixaoPrice = new JLabel("$10.75");
  298. label_ShrimpMixaoPrice.setHorizontalAlignment(SwingConstants.CENTER);
  299. label_ShrimpMixaoPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  300. label_ShrimpMixaoPrice.setBounds(198, 317, 53, 14);
  301. panel_menu.add(label_ShrimpMixaoPrice);
  302.  
  303.  
  304. /*
  305. * ------SALADS--------
  306. */
  307. JLabel lblSteak = new JLabel("Steak");
  308. lblSteak.setForeground(new Color(128, 0, 0));
  309. lblSteak.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  310. lblSteak.setBounds(44, 359, 120, 22);
  311. panel_menu.add(lblSteak);
  312.  
  313. JLabel label_SteakSaladPrice = new JLabel("$10.75");
  314. label_SteakSaladPrice.setHorizontalAlignment(SwingConstants.CENTER);
  315. label_SteakSaladPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  316. label_SteakSaladPrice.setBounds(198, 363, 53, 14);
  317. panel_menu.add(label_SteakSaladPrice);
  318.  
  319. JLabel lblChicken = new JLabel("Chicken");
  320. lblChicken.setForeground(new Color(128, 0, 0));
  321. lblChicken.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  322. lblChicken.setBounds(44, 380, 120, 22);
  323. panel_menu.add(lblChicken);
  324.  
  325. JLabel label_ChickenSaladPrice = new JLabel("$8.95");
  326. label_ChickenSaladPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  327. label_ChickenSaladPrice.setBounds(209, 384, 42, 14);
  328. panel_menu.add(label_ChickenSaladPrice);
  329.  
  330. JLabel lblLemongrassTofu = new JLabel("Lemongrass Tofu");
  331. lblLemongrassTofu.setForeground(new Color(128, 0, 0));
  332. lblLemongrassTofu.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  333. lblLemongrassTofu.setBounds(44, 402, 120, 22);
  334. panel_menu.add(lblLemongrassTofu);
  335.  
  336. JLabel label_LemongrassTofuSaladPrice = new JLabel("$8.00");
  337. label_LemongrassTofuSaladPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  338. label_LemongrassTofuSaladPrice.setBounds(209, 406, 42, 14);
  339. panel_menu.add(label_LemongrassTofuSaladPrice);
  340.  
  341. JLabel lblShrimp = new JLabel("Shrimp");
  342. lblShrimp.setForeground(new Color(128, 0, 0));
  343. lblShrimp.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  344. lblShrimp.setBounds(44, 424, 120, 22);
  345. panel_menu.add(lblShrimp);
  346.  
  347. JLabel label_ShrimpSaladPrice = new JLabel("$10.75");
  348. label_ShrimpSaladPrice.setHorizontalAlignment(SwingConstants.CENTER);
  349. label_ShrimpSaladPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  350. label_ShrimpSaladPrice.setBounds(198, 428, 53, 14);
  351. panel_menu.add(label_ShrimpSaladPrice);
  352.  
  353.  
  354. /*
  355. * ------DRINKS--------
  356. */
  357. JLabel lblWater = new JLabel("Water");
  358. lblWater.setForeground(new Color(128, 0, 0));
  359. lblWater.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  360. lblWater.setBounds(44, 467, 120, 22);
  361. panel_menu.add(lblWater);
  362.  
  363. JLabel label_WaterPrice = new JLabel("$.75");
  364. label_WaterPrice.setHorizontalAlignment(SwingConstants.CENTER);
  365. label_WaterPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  366. label_WaterPrice.setBounds(209, 471, 42, 14);
  367. panel_menu.add(label_WaterPrice);
  368.  
  369. JLabel lblCoke = new JLabel("Coke");
  370. lblCoke.setForeground(new Color(128, 0, 0));
  371. lblCoke.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  372. lblCoke.setBounds(44, 489, 120, 22);
  373. panel_menu.add(lblCoke);
  374.  
  375. JLabel label_CokePrice = new JLabel("$1.75");
  376. label_CokePrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  377. label_CokePrice.setBounds(209, 493, 42, 14);
  378. panel_menu.add(label_CokePrice);
  379.  
  380. JLabel lblTea = new JLabel("Tea");
  381. lblTea.setForeground(new Color(128, 0, 0));
  382. lblTea.setFont(new Font("Tempus Sans ITC", Font.BOLD, 12));
  383. lblTea.setBounds(44, 513, 120, 22);
  384. panel_menu.add(lblTea);
  385.  
  386. JLabel label_TeaPrice = new JLabel("$2.75");
  387. label_TeaPrice.setFont(new Font("Arial Black", Font.BOLD, 11));
  388. label_TeaPrice.setBounds(209, 517, 42, 14);
  389. panel_menu.add(label_TeaPrice);
  390.  
  391.  
  392.  
  393.  
  394. textFriedEggRollsQty = new JTextField();
  395. textFriedEggRollsQty.setBounds(280, 81, 47, 17);
  396. panel_menu.add(textFriedEggRollsQty);
  397. textFriedEggRollsQty.setColumns(10);
  398.  
  399. textSpringRollsQty = new JTextField();
  400. textSpringRollsQty.setColumns(10);
  401. textSpringRollsQty.setBounds(280, 99, 47, 17);
  402. panel_menu.add(textSpringRollsQty);
  403.  
  404. textHousePhoQty = new JTextField();
  405. textHousePhoQty.setColumns(10);
  406. textHousePhoQty.setBounds(280, 145, 47, 17);
  407. panel_menu.add(textHousePhoQty);
  408.  
  409. textShrimpPhoQty = new JTextField();
  410. textShrimpPhoQty.setColumns(10);
  411. textShrimpPhoQty.setBounds(280, 166, 47, 17);
  412. panel_menu.add(textShrimpPhoQty);
  413.  
  414. textChickenPhoQty = new JTextField();
  415. textChickenPhoQty.setColumns(10);
  416. textChickenPhoQty.setBounds(280, 187, 47, 17);
  417. panel_menu.add(textChickenPhoQty);
  418.  
  419. textBeefPhoQty = new JTextField();
  420. textBeefPhoQty.setColumns(10);
  421. textBeefPhoQty.setBounds(280, 207, 47, 17);
  422. panel_menu.add(textBeefPhoQty);
  423.  
  424. textPorkMixaoQty = new JTextField();
  425. textPorkMixaoQty.setColumns(10);
  426. textPorkMixaoQty.setBounds(280, 252, 47, 17);
  427. panel_menu.add(textPorkMixaoQty);
  428.  
  429. textChickenMixaoQty = new JTextField();
  430. textChickenMixaoQty.setColumns(10);
  431. textChickenMixaoQty.setBounds(280, 274, 47, 17);
  432. panel_menu.add(textChickenMixaoQty);
  433.  
  434. textTofuMixaoQty = new JTextField();
  435. textTofuMixaoQty.setColumns(10);
  436. textTofuMixaoQty.setBounds(280, 294, 47, 17);
  437. panel_menu.add(textTofuMixaoQty);
  438.  
  439. textShrimpMixaoQty = new JTextField();
  440. textShrimpMixaoQty.setColumns(10);
  441. textShrimpMixaoQty.setBounds(280, 315, 47, 17);
  442. panel_menu.add(textShrimpMixaoQty);
  443.  
  444. textSteakSaladQty = new JTextField();
  445. textSteakSaladQty.setColumns(10);
  446. textSteakSaladQty.setBounds(280, 361, 47, 17);
  447. panel_menu.add(textSteakSaladQty);
  448.  
  449. textChickenSaladQty = new JTextField();
  450. textChickenSaladQty.setColumns(10);
  451. textChickenSaladQty.setBounds(280, 381, 47, 17);
  452. panel_menu.add(textChickenSaladQty);
  453.  
  454. textLemongrassTofuSaladQty = new JTextField();
  455. textLemongrassTofuSaladQty.setColumns(10);
  456. textLemongrassTofuSaladQty.setBounds(280, 403, 47, 17);
  457. panel_menu.add(textLemongrassTofuSaladQty);
  458.  
  459. textShrimpSaladQty = new JTextField();
  460. textShrimpSaladQty.setColumns(10);
  461. textShrimpSaladQty.setBounds(280, 425, 47, 17);
  462. panel_menu.add(textShrimpSaladQty);
  463.  
  464. textWaterQty = new JTextField();
  465. textWaterQty.setColumns(10);
  466. textWaterQty.setBounds(280, 468, 47, 17);
  467. panel_menu.add(textWaterQty);
  468.  
  469. textCokeQty = new JTextField();
  470. textCokeQty.setColumns(10);
  471. textCokeQty.setBounds(280, 490, 47, 17);
  472. panel_menu.add(textCokeQty);
  473.  
  474. textTeaQty = new JTextField();
  475. textTeaQty.setColumns(10);
  476. textTeaQty.setBounds(280, 514, 47, 17);
  477. panel_menu.add(textTeaQty);
  478.  
  479.  
  480.  
  481.  
  482. /*
  483. * ------LOGIN PANEL--------
  484. */
  485. JPanel panel_login = new JPanel();
  486. panel_login.setBorder(new LineBorder(new Color(128, 0, 0), 6, true));
  487. panel_login.setBounds(357, 155, 229, 107);
  488. frame.getContentPane().add(panel_login);
  489. panel_login.setLayout(null);
  490.  
  491. JLabel lblUsername = new JLabel("Username:");
  492. lblUsername.setForeground(Color.BLACK);
  493. lblUsername.setFont(new Font("Tempus Sans ITC", Font.BOLD, 14));
  494. lblUsername.setBounds(18, 17, 77, 17);
  495. panel_login.add(lblUsername);
  496.  
  497. JLabel lblPassword = new JLabel("Password:");
  498. lblPassword.setForeground(Color.BLACK);
  499. lblPassword.setFont(new Font("Tempus Sans ITC", Font.BOLD, 14));
  500. lblPassword.setBounds(18, 46, 77, 22);
  501. panel_login.add(lblPassword);
  502.  
  503. JButton btnClear = new JButton("Clear");
  504. btnClear.addActionListener(new ActionListener() {
  505. public void actionPerformed(ActionEvent arg0) {
  506.  
  507. txtUsername.setText(null);
  508. txtPassword.setText(null);
  509. }
  510. });
  511. btnClear.setBounds(20, 79, 89, 17);
  512. panel_login.add(btnClear);
  513.  
  514. JButton btnLogin = new JButton("Login");
  515. btnLogin.addActionListener(new ActionListener() {
  516. public void actionPerformed(ActionEvent e) {
  517.  
  518. String password = txtPassword.getText();
  519. String username = txtUsername.getText();
  520.  
  521. if (username.contains("TSM") && password.contains("cis3260")) {
  522.  
  523. txtPassword.setText(null);
  524. txtUsername.setText(null);
  525.  
  526. JOptionPane.showMessageDialog(null, "Login Succesful", "Login Succesful",JOptionPane.INFORMATION_MESSAGE);
  527. }
  528.  
  529. else
  530. {
  531. JOptionPane.showMessageDialog(null, "Invalid login details", "Login Error",JOptionPane.ERROR_MESSAGE);
  532. }
  533. }
  534. });
  535. btnLogin.setBounds(119, 79, 89, 17);
  536. panel_login.add(btnLogin);
  537.  
  538. txtUsername = new JTextField();
  539. txtUsername.setBounds(105, 17, 110, 18);
  540. panel_login.add(txtUsername);
  541. txtUsername.setColumns(10);
  542.  
  543. txtPassword = new JPasswordField();
  544. txtPassword.setBounds(105, 48, 110, 18);
  545. panel_login.add(txtPassword);
  546.  
  547.  
  548.  
  549.  
  550. /*
  551. * ------RECEIPT PANEL--------
  552. */
  553. JPanel panel_receiptlayout = new JPanel();
  554. panel_receiptlayout.setBorder(new LineBorder(new Color(128, 0, 0), 6, true));
  555. panel_receiptlayout.setBounds(596, 11, 278, 431);
  556. frame.getContentPane().add(panel_receiptlayout);
  557. panel_receiptlayout.setLayout(null);
  558.  
  559. JLabel lblReceipt = new JLabel("Receipt");
  560. lblReceipt.setHorizontalAlignment(SwingConstants.CENTER);
  561. lblReceipt.setFont(new Font("Tempus Sans ITC", Font.BOLD, 24));
  562. lblReceipt.setBounds(10, 11, 258, 33);
  563. panel_receiptlayout.add(lblReceipt);
  564.  
  565. JPanel panel_receipt = new JPanel();
  566. panel_receipt.setBounds(10, 43, 258, 377);
  567. panel_receiptlayout.add(panel_receipt);
  568. panel_receipt.setLayout(null);
  569.  
  570. textReceipt = new JTextField();
  571. textReceipt.setFont(new Font("Tahoma", Font.PLAIN, 16));
  572. textReceipt.setBounds(0, 0, 258, 377);
  573. panel_receipt.add(textReceipt);
  574. textReceipt.setColumns(10);
  575.  
  576.  
  577.  
  578.  
  579. /*
  580. * ------BUTTONS PANEL--------
  581. */
  582. JPanel panel_3 = new JPanel();
  583. panel_3.setBorder(new LineBorder(new Color(128, 0, 0), 6, true));
  584. panel_3.setBounds(596, 560, 278, 40);
  585. frame.getContentPane().add(panel_3);
  586. panel_3.setLayout(null);
  587.  
  588. JButton btnReset = new JButton("Reset");
  589. btnReset.addActionListener(new ActionListener() {
  590. public void actionPerformed(ActionEvent arg0) {
  591.  
  592.  
  593. textFriedEggRollsQty.setText(null);
  594. textSpringRollsQty.setText(null);
  595. textHousePhoQty.setText(null);
  596. textShrimpPhoQty.setText(null);
  597. textChickenPhoQty.setText(null);
  598. textBeefPhoQty.setText(null);
  599. textPorkMixaoQty.setText(null);
  600. textChickenMixaoQty.setText(null);
  601. textTofuMixaoQty.setText(null);
  602. textShrimpMixaoQty.setText(null);
  603. textSteakSaladQty.setText(null);
  604. textChickenSaladQty.setText(null);
  605. textLemongrassTofuSaladQty.setText(null);
  606. textShrimpSaladQty.setText(null);
  607. textWaterQty.setText(null);
  608. textCokeQty.setText(null);
  609. textTeaQty.setText(null);
  610.  
  611. txtUsername.setText(null);
  612. txtPassword.setText(null);
  613.  
  614. txtDisplay.setText(null);
  615.  
  616. textReceipt.setText(null);
  617.  
  618. textTax.setText(null);
  619. textSubtotal.setText(null);
  620. textTotal.setText(null);
  621.  
  622. }
  623. });
  624. btnReset.setFont(new Font("Tahoma", Font.PLAIN, 11));
  625.  
  626. btnReset.setBounds(20, 11, 67, 17);
  627. panel_3.add(btnReset);
  628.  
  629. JButton button_Total = new JButton("Total");
  630. button_Total.addActionListener(new ActionListener() {
  631. public void actionPerformed(ActionEvent e) {
  632.  
  633. double friedeggrollstotal = friedeggrolls * Double.parseDouble(textFriedEggRollsQty.getText());
  634. double springrollstotal = springrolls * Double.parseDouble(textSpringRollsQty.getText());
  635. double housephototal = housepho * Double.parseDouble(textHousePhoQty.getText());
  636. double shrimpphototal = shrimppho * Double.parseDouble(textShrimpPhoQty.getText());
  637. double chickenphototal = chickenpho * Double.parseDouble(textChickenPhoQty.getText());
  638. double beefphototal = beefpho * Double.parseDouble(textBeefPhoQty.getText());
  639. double porkmixaototal = porkmixao * Double.parseDouble(textPorkMixaoQty.getText());
  640. double chickenmixaototal = chickenmixao * Double.parseDouble(textChickenMixaoQty.getText());
  641. double tofumixaototal = tofumixao * Double.parseDouble(textTofuMixaoQty.getText());
  642. double shrimpmixaototal = shrimpmixao * Double.parseDouble(textShrimpMixaoQty.getText());
  643. double steaksaladtotal = steaksalad * Double.parseDouble(textSteakSaladQty.getText());
  644. double chickensaladtotal = chickensalad * Double.parseDouble(textChickenSaladQty.getText());
  645. double lemongrasstofusaladtotal = lemongrasstofusalad * Double.parseDouble(textLemongrassTofuSaladQty.getText());
  646. double shrimpsaladtotal = shrimpsalad * Double.parseDouble(textShrimpSaladQty.getText());
  647. double watertotal = water * Double.parseDouble(textWaterQty.getText());
  648. double coketotal = coke * Double.parseDouble(textCokeQty.getText());
  649. double teatotal = tea * Double.parseDouble(textTeaQty.getText());
  650.  
  651. double subTotal = friedeggrollstotal + springrollstotal + housephototal + shrimpphototal + chickenphototal + beefphototal + porkmixaototal + chickenmixaototal +
  652. tofumixaototal + shrimpmixaototal + steaksaladtotal + chickensaladtotal + lemongrasstofusaladtotal + shrimpsaladtotal + watertotal + coketotal + teatotal;
  653.  
  654. double taxTotal = (tax*subTotal)/100;
  655.  
  656.  
  657. String S = String.format("$ %.2", subTotal);
  658. textSubtotal.setText(S);
  659.  
  660. String T = String.format("$ %.2", taxTotal);
  661. textTax.setText(T);
  662.  
  663. double sumTotal = subTotal + taxTotal;
  664.  
  665. String FinalTotal = String.format("$ %.2", sumTotal);
  666. textTotal.setText(FinalTotal);
  667.  
  668. }
  669. });
  670. button_Total.setFont(new Font("Tahoma", Font.PLAIN, 10));
  671.  
  672. button_Total.setBounds(97, 11, 57, 17);
  673. panel_3.add(button_Total);
  674.  
  675. JButton btnPlaceOrder = new JButton("Place Order");
  676. btnPlaceOrder.addActionListener(new ActionListener() {
  677. public void actionPerformed(ActionEvent e) {
  678. }
  679. });
  680. btnPlaceOrder.setFont(new Font("Tahoma", Font.BOLD, 10));
  681. btnPlaceOrder.setBounds(165, 11, 97, 17);
  682. panel_3.add(btnPlaceOrder);
  683.  
  684.  
  685.  
  686.  
  687. /*
  688. * --------CALCULATOR PANEL--------
  689. */
  690. JPanel panel = new JPanel();
  691. panel.setLayout(null);
  692. panel.setBorder(new EmptyBorder(5, 5, 5, 5));
  693. panel.setBounds(354, 273, 240, 403);
  694. frame.getContentPane().add(panel);
  695.  
  696. JPanel panel_1 = new JPanel();
  697. panel_1.setLayout(null);
  698. panel_1.setBorder(new LineBorder(new Color(128, 0, 0), 6, true));
  699. panel_1.setBounds(0, 0, 236, 334);
  700. panel.add(panel_1);
  701.  
  702. txtDisplay = new JTextField();
  703. txtDisplay.setColumns(10);
  704. txtDisplay.setBackground(new Color(240, 248, 255));
  705. txtDisplay.setBounds(20, 11, 188, 28);
  706. panel_1.add(txtDisplay);
  707.  
  708.  
  709. // ---------------CALCULATOR ROW 1-----------------
  710. JButton button_0 = new JButton("0");
  711. button_0.addActionListener(new ActionListener() {
  712. public void actionPerformed(ActionEvent arg0) {
  713.  
  714. String EnterNumber = txtDisplay.getText() + button_0.getText();
  715. txtDisplay.setText(EnterNumber);
  716. }
  717. });
  718. button_0.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  719. button_0.setBounds(10, 271, 45, 45);
  720. panel_1.add(button_0);
  721.  
  722. JButton button_decimal = new JButton(".");
  723. button_decimal.addActionListener(new ActionListener() {
  724. public void actionPerformed(ActionEvent e) {
  725.  
  726. if (! txtDisplay.getText().contains("."))
  727. {
  728. txtDisplay.setText(txtDisplay.getText() + button_decimal.getText());
  729. }
  730.  
  731. }
  732. });
  733. button_decimal.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  734. button_decimal.setBounds(65, 271, 45, 45);
  735. panel_1.add(button_decimal);
  736.  
  737. JButton button_plusorminus = new JButton("\u00B1");
  738. button_plusorminus.addActionListener(new ActionListener() {
  739. public void actionPerformed(ActionEvent e) {
  740.  
  741. double ops = Double.parseDouble(String.valueOf(txtDisplay.getText()));
  742. ops = ops * (-1);
  743. txtDisplay.setText(String.valueOf(ops));
  744.  
  745. }
  746. });
  747. button_plusorminus.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  748. button_plusorminus.setBounds(120, 271, 45, 45);
  749. panel_1.add(button_plusorminus);
  750.  
  751. JButton button_equals = new JButton("=");
  752. button_equals.addActionListener(new ActionListener() {
  753. public void actionPerformed(ActionEvent e) {
  754.  
  755. secondnum = Double.parseDouble(txtDisplay.getText());
  756. if(operations == "+")
  757. {
  758. result = firstnum + secondnum;
  759. answer = String.format("%.2f", result);
  760. txtDisplay.setText(answer);
  761. }
  762.  
  763. else if(operations == "-")
  764. {
  765. result = firstnum - secondnum;
  766. answer = String.format("%.2f", result);
  767. txtDisplay.setText(answer);
  768. }
  769.  
  770. else if(operations == "*")
  771. {
  772. result = firstnum * secondnum;
  773. answer = String.format("%.2f", result);
  774. txtDisplay.setText(answer);
  775. }
  776.  
  777. else if(operations == "/")
  778. {
  779. result = firstnum / secondnum;
  780. answer = String.format("%.2f", result);
  781. txtDisplay.setText(answer);
  782. }
  783.  
  784. else if(operations == "%")
  785. {
  786. result = firstnum % secondnum;
  787. answer = String.format("%.2f", result);
  788. txtDisplay.setText(answer);
  789. }
  790.  
  791. }
  792. });
  793. button_equals.setFont(new Font("Trajan Pro", Font.BOLD, 16));
  794. button_equals.setBounds(175, 271, 45, 45);
  795. panel_1.add(button_equals);
  796.  
  797. // ---------------CALCULATOR ROW 2-----------------
  798. JButton button_1 = new JButton("1");
  799. button_1.addActionListener(new ActionListener() {
  800. public void actionPerformed(ActionEvent arg0) {
  801.  
  802. String EnterNumber = txtDisplay.getText() + button_1.getText();
  803. txtDisplay.setText(EnterNumber);
  804. }
  805. });
  806. button_1.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  807. button_1.setBounds(10, 215, 45, 45);
  808. panel_1.add(button_1);
  809.  
  810. JButton button_2 = new JButton("2");
  811. button_2.addActionListener(new ActionListener() {
  812. public void actionPerformed(ActionEvent arg0) {
  813.  
  814. String EnterNumber = txtDisplay.getText() + button_2.getText();
  815. txtDisplay.setText(EnterNumber);
  816. }
  817. });
  818. button_2.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  819. button_2.setBounds(65, 215, 45, 45);
  820. panel_1.add(button_2);
  821.  
  822. JButton button_3 = new JButton("3");
  823. button_3.addActionListener(new ActionListener() {
  824. public void actionPerformed(ActionEvent arg0) {
  825.  
  826. String EnterNumber = txtDisplay.getText() + button_3.getText();
  827. txtDisplay.setText(EnterNumber);
  828. }
  829. });
  830. button_3.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  831. button_3.setBounds(120, 215, 45, 45);
  832. panel_1.add(button_3);
  833.  
  834. JButton button_divide = new JButton("/");
  835. button_divide.addActionListener(new ActionListener() {
  836. public void actionPerformed(ActionEvent e) {
  837.  
  838. firstnum = Double.parseDouble(txtDisplay.getText());
  839. txtDisplay.setText("");
  840. operations = "/";
  841.  
  842. }
  843. });
  844. button_divide.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  845. button_divide.setBounds(175, 215, 45, 45);
  846. panel_1.add(button_divide);
  847.  
  848. // ---------------CALCULATOR ROW 4-----------------
  849. JButton button_4 = new JButton("4");
  850. button_4.addActionListener(new ActionListener() {
  851. public void actionPerformed(ActionEvent arg0) {
  852.  
  853. String EnterNumber = txtDisplay.getText() + button_4.getText();
  854. txtDisplay.setText(EnterNumber);
  855. }
  856. });
  857. button_4.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  858. button_4.setBounds(10, 159, 45, 45);
  859. panel_1.add(button_4);
  860.  
  861. JButton button_5 = new JButton("5");
  862. button_5.addActionListener(new ActionListener() {
  863. public void actionPerformed(ActionEvent arg0) {
  864.  
  865. String EnterNumber = txtDisplay.getText() + button_5.getText();
  866. txtDisplay.setText(EnterNumber);
  867. }
  868. });
  869. button_5.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  870. button_5.setBounds(65, 159, 45, 45);
  871. panel_1.add(button_5);
  872.  
  873. JButton button_6 = new JButton("6");
  874. button_6.addActionListener(new ActionListener() {
  875. public void actionPerformed(ActionEvent arg0) {
  876.  
  877. String EnterNumber = txtDisplay.getText() + button_6.getText();
  878. txtDisplay.setText(EnterNumber);
  879. }
  880. });
  881. button_6.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  882. button_6.setBounds(120, 159, 45, 45);
  883. panel_1.add(button_6);
  884.  
  885. JButton button_multiply = new JButton("*");
  886. button_multiply.addActionListener(new ActionListener() {
  887. public void actionPerformed(ActionEvent e) {
  888.  
  889. firstnum = Double.parseDouble(txtDisplay.getText());
  890. txtDisplay.setText("");
  891. operations = "*";
  892.  
  893. }
  894. });
  895. button_multiply.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  896. button_multiply.setBounds(175, 159, 45, 45);
  897. panel_1.add(button_multiply);
  898.  
  899.  
  900. // ---------------CALCULATOR ROW 5-----------------
  901. JButton button_7 = new JButton("7");
  902. button_7.addActionListener(new ActionListener() {
  903. public void actionPerformed(ActionEvent arg0) {
  904.  
  905. String EnterNumber = txtDisplay.getText() + button_7.getText();
  906. txtDisplay.setText(EnterNumber);
  907. }
  908. });
  909. button_7.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  910. button_7.setBounds(10, 103, 45, 45);
  911. panel_1.add(button_7);
  912.  
  913. JButton button_8 = new JButton("8");
  914. button_8.addActionListener(new ActionListener() {
  915. public void actionPerformed(ActionEvent arg0) {
  916.  
  917. String EnterNumber = txtDisplay.getText() + button_8.getText();
  918. txtDisplay.setText(EnterNumber);
  919. }
  920. });
  921. button_8.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  922. button_8.setBounds(65, 103, 45, 45);
  923. panel_1.add(button_8);
  924.  
  925. JButton button_9 = new JButton("9");
  926. button_9.addActionListener(new ActionListener() {
  927. public void actionPerformed(ActionEvent arg0) {
  928.  
  929. String EnterNumber = txtDisplay.getText() + button_9.getText();
  930. txtDisplay.setText(EnterNumber);
  931. }
  932. });
  933. button_9.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  934. button_9.setBounds(120, 103, 45, 45);
  935. panel_1.add(button_9);
  936.  
  937. JButton button_subtract = new JButton("-");
  938. button_subtract.addActionListener(new ActionListener() {
  939. public void actionPerformed(ActionEvent e) {
  940.  
  941. firstnum = Double.parseDouble(txtDisplay.getText());
  942. txtDisplay.setText("");
  943. operations = "-";
  944.  
  945. }
  946. });
  947. button_subtract.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  948. button_subtract.setBounds(175, 103, 45, 45);
  949. panel_1.add(button_subtract);
  950.  
  951.  
  952. // ---------------CALCULATOR ROW 5-----------------
  953. JButton button_backspace = new JButton("\u00AB");
  954. button_backspace.addActionListener(new ActionListener() {
  955. public void actionPerformed(ActionEvent arg0) {
  956.  
  957. String backspace=null;
  958.  
  959. if (txtDisplay.getText().length() > 0) {
  960. StringBuilder strB = new StringBuilder(txtDisplay.getText());
  961. strB.deleteCharAt(txtDisplay.getText().length()-1);
  962. backspace = strB.toString();
  963. txtDisplay.setText(backspace);
  964. }
  965.  
  966. }
  967.  
  968. private StringBuilder newStringBuilder(String text) {
  969. return null;
  970. }
  971. });
  972. button_backspace.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  973. button_backspace.setBounds(10, 47, 45, 45);
  974. panel_1.add(button_backspace);
  975.  
  976. JButton button_clear = new JButton("C");
  977. button_clear.addActionListener(new ActionListener() {
  978. public void actionPerformed(ActionEvent arg0) {
  979.  
  980. txtDisplay.setText(null);
  981. }
  982. });
  983. button_clear.setFont(new Font("Trajan Pro", Font.BOLD, 13));
  984. button_clear.setBounds(65, 48, 45, 45);
  985. panel_1.add(button_clear);
  986.  
  987. JButton button_remainder = new JButton("%");
  988. button_remainder.addActionListener(new ActionListener() {
  989. public void actionPerformed(ActionEvent e) {
  990.  
  991. firstnum = Double.parseDouble(txtDisplay.getText());
  992. txtDisplay.setText("");
  993. operations = "%";
  994.  
  995. }
  996. });
  997. button_remainder.setFont(new Font("Trajan Pro", Font.BOLD, 12));
  998. button_remainder.setBounds(120, 48, 45, 45);
  999. panel_1.add(button_remainder);
  1000.  
  1001. JButton button_add = new JButton("+");
  1002. button_add.addActionListener(new ActionListener() {
  1003. public void actionPerformed(ActionEvent e) {
  1004.  
  1005. firstnum = Double.parseDouble(txtDisplay.getText());
  1006. txtDisplay.setText("");
  1007. operations = "+";
  1008.  
  1009. }
  1010. });
  1011. button_add.setFont(new Font("Trajan Pro", Font.BOLD, 14));
  1012. button_add.setBounds(175, 47, 45, 45);
  1013. panel_1.add(button_add);
  1014.  
  1015.  
  1016.  
  1017.  
  1018. /*
  1019. * --------TOTAL PANEL--------
  1020. */
  1021. JPanel panel_total = new JPanel();
  1022. panel_total.setLayout(null);
  1023. panel_total.setBorder(new LineBorder(new Color(128, 0, 0), 6, true));
  1024. panel_total.setBounds(596, 453, 278, 100);
  1025. frame.getContentPane().add(panel_total);
  1026.  
  1027. JLabel lblTax = new JLabel("Tax");
  1028. lblTax.setFont(new Font("Tempus Sans ITC", Font.BOLD, 17));
  1029. lblTax.setBounds(10, 22, 33, 14);
  1030. panel_total.add(lblTax);
  1031.  
  1032. JLabel lblSubtotal = new JLabel("Subtotal");
  1033. lblSubtotal.setFont(new Font("Tempus Sans ITC", Font.BOLD, 17));
  1034. lblSubtotal.setBounds(116, 22, 67, 14);
  1035. panel_total.add(lblSubtotal);
  1036.  
  1037. JLabel lblTotal = new JLabel("Total");
  1038. lblTotal.setFont(new Font("Tempus Sans ITC", Font.BOLD, 24));
  1039. lblTotal.setBounds(56, 56, 67, 22);
  1040. panel_total.add(lblTotal);
  1041.  
  1042. textTax = new JTextField();
  1043. textTax.setBounds(46, 19, 60, 24);
  1044. panel_total.add(textTax);
  1045. textTax.setColumns(10);
  1046.  
  1047. textSubtotal = new JTextField();
  1048. textSubtotal.setColumns(10);
  1049. textSubtotal.setBounds(193, 21, 67, 24);
  1050. panel_total.add(textSubtotal);
  1051.  
  1052. textTotal = new JTextField();
  1053. textTotal.setFont(new Font("Tahoma", Font.PLAIN, 8));
  1054. textTotal.setColumns(10);
  1055. textTotal.setBounds(116, 56, 80, 22);
  1056. panel_total.add(textTotal);
  1057.  
  1058.  
  1059. }
  1060. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement