Advertisement
Guest User

Untitled

a guest
May 16th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.util.ArrayList;
  6. import java.util.Arrays;
  7.  
  8. public class NewReservationFrame extends JFrame{
  9.  
  10. private String month, year;
  11. private int day;
  12. private JComboBox months, days, years, rooms, hour, min, AMPM, mealPlans;
  13. private JTextArea fullName, DOB, phoneNum, address, email
  14. , prefMethodOfCon, ccName, ccNum, ccExp, ccCompany
  15. , ccSC, roomNum;
  16. private JLabel nameLabel, DOBLabel, phoneNumLabel, emailLabel
  17. , prefMethodOfConLabel, ccNameLabel, ccNumLabel, ccExpLabel
  18. , ccCompanyLabel, ccSCLabel, addressLabel, guest, room, cc
  19. , roomNameLabel, roomNumLabel, dateLabel, timeLabel, mealPlanLabel;
  20. private JButton reserve, cancel;
  21.  
  22. public NewReservationFrame() {
  23. createComponents();
  24. this.setTitle("New Reservation");
  25. this.setExtendedState(JFrame.MAXIMIZED_BOTH);
  26. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  27.  
  28. //TODO create new reservation frame
  29. }
  30.  
  31. public void createComponents(){
  32. String[] month = {"Jan", "Feb","Mar", "Apr" ,"May", "Jun", "Jul", "Aug",
  33. "Sept", "Oct", "Nov", "Dec"};
  34. String[] year = {"2019", "2020"};
  35. String[] roomSelection = {"Aqua World" , "Small Party Room", "Medium Party Room"
  36. , "Karaoke Lounge", "Adult Billards Lounge"};
  37. String[] days31 = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
  38. "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28",
  39. "29", "30", "31"};
  40. String[] hours = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
  41. String[] minutes = {"05", "10", "15", "20", "25", "30", "35", "40",
  42. "45", "50", "55"};
  43. String[] timeOfDay = {"AM", "PM"};
  44. String[] mealPlan = {"Basic", "Bronze", "Silver", "Gold", "Platinum"};
  45.  
  46. months = new JComboBox(month);
  47. rooms = new JComboBox(roomSelection);
  48. days = new JComboBox(days31);
  49. years = new JComboBox(year);
  50. AMPM = new JComboBox(timeOfDay);
  51. hour = new JComboBox(hours);
  52. min = new JComboBox(minutes);
  53. mealPlans = new JComboBox(mealPlan);
  54.  
  55.  
  56. fullName = new JTextArea(1, 20);
  57. DOB = new JTextArea(1, 10);
  58. phoneNum = new JTextArea(1, 10);
  59. address = new JTextArea(1, 20);
  60. email = new JTextArea(1, 20);
  61. prefMethodOfCon = new JTextArea(1, 10);
  62. ccName = new JTextArea(1, 20);
  63. ccNum = new JTextArea(1, 16);
  64. ccExp = new JTextArea(1, 5);
  65. ccCompany = new JTextArea(1, 15);
  66. ccSC = new JTextArea(1, 10);
  67. roomNum = new JTextArea(1, 10);
  68.  
  69. nameLabel = new JLabel("Name: ");
  70. DOBLabel = new JLabel("Date Of Birth: ");
  71. phoneNumLabel = new JLabel("Phone Number: ");
  72. addressLabel = new JLabel("Address: ");
  73. emailLabel = new JLabel("Email: ");
  74. prefMethodOfConLabel = new JLabel("Preferred Method of Contact: ");
  75. ccNameLabel = new JLabel("Name on Credit Card: ");
  76. ccNumLabel = new JLabel("Credit Card Number: ");
  77. ccExpLabel = new JLabel("Exp Date: ");
  78. ccCompanyLabel = new JLabel("Company: ");
  79. ccSCLabel = new JLabel("Security Code: ");
  80. guest = new JLabel("Guest Info");
  81. cc = new JLabel("Credit Card");
  82. room = new JLabel("Room");
  83. roomNameLabel = new JLabel("Room Type: ");
  84. roomNumLabel = new JLabel("Room Number");
  85. dateLabel = new JLabel("Date");
  86. timeLabel = new JLabel("Time");
  87. mealPlanLabel = new JLabel("Meal Plans");
  88.  
  89. reserve = new JButton("Reserve");
  90. cancel = new JButton("Cancel");
  91.  
  92. ActionListener button = new ButtonListener();
  93. reserve.addActionListener(button);
  94. cancel.addActionListener(button);
  95.  
  96.  
  97. JPanel panel = new JPanel(null);
  98.  
  99. //GUEST INFO
  100. guest.setFont(new Font(Font.SERIF, Font.BOLD, 30));
  101. guest.setBounds(10, 15, 200, 30);
  102. panel.add(guest);
  103.  
  104. //Name
  105. nameLabel.setBounds(10, 50, 50, 10);
  106. panel.add(nameLabel);
  107. fullName.setBounds(55, 50, 300, 15);
  108. panel.add(fullName);
  109.  
  110. //Date of Birth
  111. DOBLabel.setBounds(10, 90, 90, 10);
  112. panel.add(DOBLabel);
  113. DOB.setBounds(100, 90, 100, 15);
  114. panel.add(DOB);
  115.  
  116. //Phone #
  117. phoneNumLabel.setBounds(10, 130, 100, 10);
  118. panel.add(phoneNumLabel);
  119. phoneNum.setBounds(110, 130, 150, 15);
  120. panel.add(phoneNum);
  121.  
  122. //Address
  123. addressLabel.setBounds(10, 170, 100, 10);
  124. panel.add(addressLabel);
  125. address.setBounds(70, 170, 350, 15);
  126. panel.add(address);
  127.  
  128. //Email
  129. emailLabel.setBounds(10, 210, 100, 10);
  130. panel.add(emailLabel);
  131. email.setBounds(60, 210, 300, 15);
  132. panel.add(email);
  133.  
  134. //Preferred Method of Contact
  135. prefMethodOfConLabel.setBounds(10, 250, 200, 10);
  136. panel.add(prefMethodOfConLabel);
  137. prefMethodOfCon.setBounds(200, 250, 200, 15);
  138. panel.add(prefMethodOfCon);
  139.  
  140. //CC INFO
  141. cc.setFont(new Font(Font.SERIF, Font.BOLD, 30));
  142. cc.setBounds(1000, 15, 200, 30);
  143. panel.add(cc);
  144.  
  145. //CC Name
  146. ccNameLabel.setBounds(900, 50 , 200, 10);
  147. panel.add(ccNameLabel);
  148. ccName.setBounds(1050, 50, 350, 15);
  149. panel.add(ccName);
  150.  
  151. //CC Number
  152. ccNumLabel.setBounds(900, 90 , 200, 10);
  153. panel.add(ccNumLabel);
  154. ccNum.setBounds(1030, 90, 350, 15);
  155. panel.add(ccNum);
  156.  
  157. //CC Exp
  158. ccExpLabel.setBounds(900, 130 , 200, 15);
  159. panel.add(ccExpLabel);
  160. ccExp.setBounds(960, 130, 200, 15);
  161. panel.add(ccExp);
  162.  
  163. //CC company
  164. ccCompanyLabel.setBounds(900, 170 , 200, 15);
  165. panel.add(ccCompanyLabel);
  166. ccCompany.setBounds(970, 170, 200, 15);
  167. panel.add(ccCompany);
  168.  
  169. //Security code
  170. ccSCLabel.setBounds(900, 210 , 200, 15);
  171. panel.add(ccSCLabel);
  172. ccSC.setBounds(1000, 210, 200, 15);
  173. panel.add(ccSC);
  174.  
  175. //ROOM INFO
  176. room.setFont(new Font(Font.SERIF, Font.BOLD, 30));
  177. room.setBounds(10, 300, 200, 30);
  178. panel.add(room);
  179.  
  180. //Room Name
  181. roomNameLabel.setBounds(10, 340, 200, 20);
  182. panel.add(roomNameLabel);
  183. rooms.setBounds(90, 325, 200, 50);
  184. panel.add(rooms);
  185. rooms.getSelectedItem();
  186.  
  187. //Room Num
  188. roomNumLabel.setBounds(300, 340, 200, 20);
  189. panel.add(roomNumLabel);
  190. roomNum.setBounds(400, 340, 200, 20);
  191. panel.add(roomNum);
  192.  
  193. //Date
  194. dateLabel.setBounds(10, 380, 200, 20);
  195. panel.add(dateLabel);
  196. months.setBounds(40, 370, 70, 50);
  197. panel.add(months);
  198. months.getSelectedItem();
  199. days.setBounds(110, 370, 70, 50);
  200. panel.add(days);
  201. days.getSelectedItem();
  202. years.setBounds(180, 370, 90, 50);
  203. panel.add(years);
  204. years.getSelectedItem();
  205.  
  206. //Time
  207. timeLabel.setBounds(10, 440, 200, 20);
  208. panel.add(timeLabel);
  209. hour.setBounds(40, 430, 70, 50);
  210. panel.add(hour);
  211. hour.getSelectedItem();
  212. min.setBounds(110, 430, 70, 50);
  213. panel.add(min);
  214. min.getSelectedItem();
  215. AMPM.setBounds(180, 430, 90, 50);
  216. panel.add(AMPM);
  217. AMPM.getSelectedItem();
  218.  
  219. //Meal Plan
  220. mealPlanLabel.setFont(new Font(Font.SERIF, Font.BOLD, 30));
  221. mealPlanLabel.setBounds(1000, 300, 200, 30);
  222. panel.add(mealPlanLabel);
  223. mealPlans.setBounds(1000, 330, 100, 50);
  224. panel.add(mealPlans);
  225.  
  226. reserve.setBounds(500, 700, 100, 30);
  227. cancel.setBounds(600, 700, 100, 30);
  228. panel.add(reserve);
  229. panel.add(cancel);
  230.  
  231. this.add(panel);
  232.  
  233. }
  234.  
  235. class ButtonListener implements ActionListener{
  236. public void actionPerformed(ActionEvent click){
  237. Component button = (Component) click.getSource();
  238. JFrame frame = (JFrame) SwingUtilities.getRoot(button);
  239. frame.setVisible(false);
  240. }
  241. }
  242.  
  243.  
  244.  
  245. public static void main(String[] args){
  246. NewReservationFrame n = new NewReservationFrame();
  247. n.setVisible(true);
  248. }
  249.  
  250.  
  251.  
  252.  
  253.  
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement