Guest User

Untitled

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