Guest User

Untitled

a guest
Nov 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. package org.lu.ics.uppgift;
  2.  
  3. import java.awt.EventQueue;
  4. import java.awt.Font;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7.  
  8. import javax.swing.JButton;
  9. import javax.swing.JFrame;
  10. import javax.swing.JLabel;
  11. import javax.swing.JSeparator;
  12. import javax.swing.JTextField;
  13. import javax.swing.SwingConstants;
  14.  
  15.  
  16. import javax.swing.JTextArea;
  17.  
  18. public class PersonApplication {
  19.  
  20. private JFrame frame;
  21. private JTextField textField_Name;
  22. private JTextField textField_pNbr;
  23. private JTextField textField_AccNbr;
  24. private JTextField textField_3;
  25. private JButton btnAddPerson;
  26. private JButton btnRemovePerson;
  27. private JLabel lblFullName;
  28. private JLabel lblSocialSecurityNumber;
  29. private JButton btnAddAccountTo;
  30. private JSeparator separator;
  31. private JSeparator separator_1;
  32. private JLabel lblAccounts;
  33. private JSeparator separator_2;
  34. private JLabel lblWelcomeToAtm;
  35. private JLabel lblPleaseEnterName;
  36. private JLabel lblAccountNumber;
  37. private JButton btnNewButton;
  38. private JLabel lblAmount;
  39. private JButton btnWithdraw;
  40. private JButton btnCredit;
  41. private JLabel lblIfNoPlease;
  42. private JLabel lblResponse_Account;
  43. private JLabel lblResponse_Person;
  44. private JLabel lblResponse_Balance;
  45. private JButton btnFindPerson;
  46.  
  47. private Controller controller;
  48. private PersonRegister personRegister;
  49.  
  50. /**
  51. * Launch the application.
  52. */
  53. public static void main(String[] args) {
  54. EventQueue.invokeLater(new Runnable() {
  55. public void run() {
  56. try {
  57. PersonApplication window = new PersonApplication();
  58. window.frame.setVisible(true);
  59. } catch (Exception e) {
  60. e.printStackTrace();
  61. }
  62. }
  63. });
  64. }
  65.  
  66. /**
  67. * Create the application.
  68. */
  69. public PersonApplication() {
  70. initialize();
  71. }
  72.  
  73. /**
  74. * Initialize the contents of the frame.
  75. */
  76. private void initialize() {
  77. frame = new JFrame();
  78. frame.setBounds(100, 100, 776, 561);
  79. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  80.  
  81. // controller.addCustomer(cNumber, cName);
  82. //lblResponse.setText("Response: Sparat");
  83.  
  84. btnAddPerson = new JButton("Add Person");
  85. btnAddPerson.addActionListener(new ActionListener() {
  86. public void actionPerformed(ActionEvent e) {
  87. String pNbr = textField_pNbr.getText();
  88. String name = textField_Name.getText();
  89. controller.addPerson(pNbr, name);
  90. lblResponse_Person.setText("Response: Saved");
  91. }
  92. }
  93. );
  94. btnAddPerson.setBounds(412, 114, 159, 23);
  95. frame.getContentPane().add(btnAddPerson);
  96. btnAddPerson = new JButton("Add New Person");
  97.  
  98.  
  99. frame.getContentPane().setLayout(null);
  100. frame.getContentPane().add(btnAddPerson);
  101.  
  102.  
  103. btnFindPerson = new JButton("Find Person");
  104. btnFindPerson.addActionListener(new ActionListener() {
  105. public void actionPerformed(ActionEvent arg0) {
  106. String pNbr = textField_pNbr.getText();
  107. String tmpPerson = controller.findPerson(pNbr);
  108. if (tmpPerson != null) {
  109. textField_Name.setText(tmpPerson);
  110. }
  111. }
  112. });
  113. btnFindPerson.setBounds(412, 46, 159, 23);
  114. frame.getContentPane().add(btnFindPerson);
  115.  
  116. btnRemovePerson = new JButton("Remove Person");
  117. btnRemovePerson.addActionListener(new ActionListener() {
  118. public void actionPerformed(ActionEvent arg0) {
  119. String pNbr = textField_pNbr.getText();
  120. controller.removePerson(pNbr);
  121.  
  122. }
  123. });
  124. btnRemovePerson.setBounds(412, 80, 159, 23);
  125. frame.getContentPane().add(btnRemovePerson);
  126.  
  127. textField_Name = new JTextField();
  128. textField_Name.setBounds(179, 69, 142, 20);
  129. frame.getContentPane().add(textField_Name);
  130. textField_Name.setColumns(10);
  131.  
  132. lblFullName = new JLabel("Full name:");
  133. lblFullName.setBounds(110, 72, 75, 14);
  134. frame.getContentPane().add(lblFullName);
  135.  
  136. lblSocialSecurityNumber = new JLabel("Personal identity number:");
  137. lblSocialSecurityNumber.setBounds(21, 97, 149, 14);
  138. frame.getContentPane().add(lblSocialSecurityNumber);
  139.  
  140. textField_pNbr = new JTextField();
  141. textField_pNbr.setBounds(179, 94, 142, 20);
  142. frame.getContentPane().add(textField_pNbr);
  143. textField_pNbr.setColumns(10);
  144.  
  145. btnAddAccountTo = new JButton("Add New Account to Person");
  146. btnAddAccountTo.addActionListener(new ActionListener() {
  147. public void actionPerformed(ActionEvent arg0) {
  148. }
  149. });
  150. btnAddAccountTo.setBounds(404, 216, 193, 23);
  151. frame.getContentPane().add(btnAddAccountTo);
  152.  
  153. separator = new JSeparator();
  154. separator.setBounds(258, 157, 237, 2);
  155. frame.getContentPane().add(separator);
  156.  
  157. separator_1 = new JSeparator();
  158. separator_1.setOrientation(SwingConstants.VERTICAL);
  159. separator_1.setBounds(382, 349, 41, 140);
  160. frame.getContentPane().add(separator_1);
  161.  
  162. lblAccounts = new JLabel("ACCOUNT DISPLAY");
  163. lblAccounts.setFont(new Font("Tahoma", Font.BOLD, 12));
  164. lblAccounts.setBounds(123, 318, 132, 31);
  165. frame.getContentPane().add(lblAccounts);
  166.  
  167. separator_2 = new JSeparator();
  168. separator_2.setBounds(258, 322, 237, 2);
  169. frame.getContentPane().add(separator_2);
  170.  
  171. lblWelcomeToAtm = new JLabel("Welcome to ATM!");
  172. lblWelcomeToAtm.setFont(new Font("Arial", Font.ITALIC, 18));
  173. lblWelcomeToAtm.setBounds(309, 11, 186, 14);
  174. frame.getContentPane().add(lblWelcomeToAtm);
  175.  
  176. lblPleaseEnterName = new JLabel("Please enter name and personal identity number (obligatory).");
  177. lblPleaseEnterName.setFont(new Font("Tahoma", Font.ITALIC, 11));
  178. lblPleaseEnterName.setBounds(39, 44, 335, 14);
  179. frame.getContentPane().add(lblPleaseEnterName);
  180.  
  181. textField_AccNbr = new JTextField();
  182. textField_AccNbr.setBounds(169, 217, 142, 20);
  183. frame.getContentPane().add(textField_AccNbr);
  184. textField_AccNbr.setColumns(10);
  185.  
  186. lblAccountNumber = new JLabel("Account number:");
  187. lblAccountNumber.setBounds(58, 220, 112, 14);
  188. frame.getContentPane().add(lblAccountNumber);
  189.  
  190. btnNewButton = new JButton("Show accounts");
  191. btnNewButton.addActionListener(new ActionListener() {
  192. public void actionPerformed(ActionEvent arg0) {
  193.  
  194. }
  195. });
  196. btnNewButton.setBounds(318, 289, 132, 23);
  197. frame.getContentPane().add(btnNewButton);
  198.  
  199.  
  200. textField_3 = new JTextField();
  201. textField_3.setBounds(474, 349, 199, 23);
  202. frame.getContentPane().add(textField_3);
  203. textField_3.setColumns(10);
  204.  
  205. lblAmount = new JLabel("Amount:");
  206. lblAmount.setBounds(412, 349, 89, 20);
  207. frame.getContentPane().add(lblAmount);
  208.  
  209. btnWithdraw = new JButton("Withdraw");
  210. btnWithdraw.setBounds(457, 393, 89, 23);
  211. frame.getContentPane().add(btnWithdraw);
  212.  
  213. btnCredit = new JButton("Credit");
  214. btnCredit.setBounds(580, 393, 89, 23);
  215. frame.getContentPane().add(btnCredit);
  216.  
  217. lblIfNoPlease = new JLabel("If you wish to make a new account, please enter prefered account number and press \"Add New Account to Person\" to proceed.");
  218. lblIfNoPlease.setFont(new Font("Tahoma", Font.ITALIC, 11));
  219. lblIfNoPlease.setBounds(39, 192, 656, 14);
  220. frame.getContentPane().add(lblIfNoPlease);
  221.  
  222. lblResponse_Account = new JLabel("Response:");
  223. lblResponse_Account.setFont(new Font("Tahoma", Font.ITALIC, 11));
  224. lblResponse_Account.setBounds(610, 216, 132, 23);
  225. frame.getContentPane().add(lblResponse_Account);
  226.  
  227. lblResponse_Person = new JLabel("Response:");
  228. lblResponse_Person.setFont(new Font("Tahoma", Font.ITALIC, 11));
  229. lblResponse_Person.setBounds(610, 82, 140, 19);
  230. frame.getContentPane().add(lblResponse_Person);
  231.  
  232. lblResponse_Balance = new JLabel("RESPONSE3");
  233. lblResponse_Balance.setFont(new Font("Tahoma", Font.ITALIC, 11));
  234. lblResponse_Balance.setBounds(523, 439, 94, 25);
  235. frame.getContentPane().add(lblResponse_Balance);
  236.  
  237. JTextArea textArea_Display = new JTextArea();
  238. textArea_Display.setBounds(110, 370, 164, 77);
  239. frame.getContentPane().add(textArea_Display);
  240.  
  241. personRegister = new PersonRegister();
  242. controller = new Controller(personRegister, frame);
  243. }
  244. }
Add Comment
Please, Sign In to add comment