Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. package lab7;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.awt.GridLayout;
  6. import java.sql.SQLException;
  7.  
  8. import javax.swing.*;
  9.  
  10. @SuppressWarnings("serial")
  11. public class Window extends JFrame
  12. {
  13. private JToolBar navToolBar;
  14. private JPanel center;
  15. private JButton next;
  16. private JButton previous;
  17. private JButton first;
  18. private JButton last;
  19. private JButton add;
  20. private JButton remove;
  21. private JButton save;
  22. private JButton edit;
  23. private JButton search;
  24. private JButton cancel;
  25. private JTextField current;
  26. private JTextField idField;
  27. private JTextField nameField;
  28. private JTextField ageField;
  29. private JLabel idLabel;
  30. private JLabel nameLabel;
  31. private JLabel ageLabel;
  32. private Controller personController;
  33.  
  34. public Window() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
  35. {
  36. super("Evidenta persoane");
  37. this.setSize(500, 300);
  38. this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  39. this.setLayout(new BorderLayout());
  40.  
  41. this.navToolBar = new JToolBar();
  42.  
  43. this.first = new JButton();
  44. this.first.setIcon(new ImageIcon("Imagini/MoveFirst.png"));
  45. this.first.setName("first");
  46.  
  47. this.previous = new JButton();
  48. this.previous.setIcon(new ImageIcon("Imagini/MovePrevious.png"));
  49. this.previous.setName("previous");
  50.  
  51. this.next = new JButton();
  52. this.next.setIcon(new ImageIcon("Imagini/MoveNext.png"));
  53. this.next.setName("next");
  54.  
  55. this.last = new JButton();
  56. this.last.setIcon(new ImageIcon("Imagini/MoveLast.png"));
  57. this.last.setName("last");
  58.  
  59. this.add = new JButton();
  60. this.add.setIcon(new ImageIcon("Imagini/Add.png"));
  61. this.add.setName("add");
  62.  
  63. this.edit = new JButton();
  64. this.edit.setIcon(new ImageIcon("Imagini/Edit.png"));
  65. this.edit.setName("edit");
  66.  
  67. this.remove = new JButton();
  68. this.remove.setIcon(new ImageIcon("Imagini/Delete.png"));
  69. this.remove.setName("remove")
  70. ;
  71. this.search = new JButton();
  72. this.search.setIcon(new ImageIcon("Imagini/find.jpg"));
  73. this.search.setName("search");
  74.  
  75. this.save = new JButton();
  76. this.save.setIcon(new ImageIcon("Imagini/save.jpg"));
  77. this.save.setName("save");
  78.  
  79. this.cancel = new JButton();
  80. this.cancel.setIcon(new ImageIcon("Imagini/undo.jpg"));
  81. this.cancel.setName("cancel");
  82.  
  83. this.current = new JTextField();
  84. this.current.setEditable(false);
  85.  
  86. this.navToolBar.add(first);
  87. this.navToolBar.add(previous);
  88. this.navToolBar.add(current);
  89. this.navToolBar.add(next);
  90. this.navToolBar.add(last);
  91. this.navToolBar.add(add);
  92. this.navToolBar.add(edit);
  93. this.navToolBar.add(remove);
  94. this.navToolBar.add(search);
  95. this.navToolBar.add(save);
  96. this.navToolBar.add(cancel);
  97.  
  98. this.getContentPane().add(navToolBar, BorderLayout.NORTH);
  99.  
  100. this.center = new JPanel();
  101. this.center.setLayout(new GridLayout(3, 2));
  102. this.center.setPreferredSize(new Dimension(60, 40));
  103. this.idLabel = new JLabel();
  104. this.idLabel.setText("ID");
  105. this.nameLabel = new JLabel();
  106. this.nameLabel.setText("Nume");
  107. this.ageLabel = new JLabel();
  108. this.ageLabel.setText("Varsta");
  109. this.idField = new JTextField();
  110. this.nameField = new JTextField();
  111. this.ageField = new JTextField();
  112. this.center.add(idLabel);
  113. this.center.add(idField);
  114. this.center.add(nameLabel);
  115. this.center.add(nameField);
  116. this.center.add(ageLabel);
  117. this.center.add(ageField);
  118.  
  119. this.personController = new Controller(this.current, this.idField, this.nameField,
  120. this.ageField, this.next, this.previous, this.first, this.last, this.add,
  121. this.remove, this.save, this.edit, this.search, this.cancel);
  122. this.personController.initialise();
  123.  
  124. this.next.addActionListener(personController);
  125. this.previous.addActionListener(personController);
  126. this.first.addActionListener(personController);
  127. this.last.addActionListener(personController);
  128. this.search.addActionListener(personController);
  129. this.remove.addActionListener(personController);
  130. this.edit.addActionListener(personController);
  131. this.add.addActionListener(personController);
  132. this.cancel.addActionListener(personController);
  133. this.save.addActionListener(personController);
  134.  
  135. this.getContentPane().add(center, BorderLayout.CENTER);
  136.  
  137.  
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement