Lowe576

Untitled

May 30th, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. package library;
  2.  
  3. /**
  4. *
  5. * @author Lowe
  6. */
  7. import java.awt.*;
  8. import java.awt.event.*;
  9. import javax.swing.*;
  10. import java.io.*;
  11.  
  12. public class Gui {
  13.  
  14. private JFrame frame = new JFrame("Bibblan");
  15. private JPanel background, centerPanel, southPanel;
  16. private JLabel l_isbn,l_title, l_reclaim,l_lend,l_storage;
  17. private JTextField tf_isbn,tf_title, tf_reclaim,tf_lend,tf_storage;
  18. private JButton b_find,b_reclaim,b_lend,b_clear,b_newBook,b_save,b_load;
  19. private Book findB;
  20. private Library libraryN;
  21.  
  22.  
  23. public Gui(Library l){
  24. libraryN = l;
  25. background = new JPanel();
  26. background.setLayout((new BorderLayout()));
  27. centerPanel = new JPanel();
  28. background.setBorder(BorderFactory.createLineBorder(Color.BLUE,9,false));
  29.  
  30. centerPanel.setLayout((new GridLayout(5,2)));
  31. southPanel = new JPanel();
  32. southPanel.setLayout((new GridLayout(3,2)));
  33.  
  34. b_find = new JButton("find");
  35. b_reclaim = new JButton("return");
  36. b_lend = new JButton("lend");
  37. b_clear = new JButton("clear");
  38. b_newBook = new JButton("Add");
  39. b_save = new JButton("save");
  40. b_load = new JButton("load");
  41.  
  42. southPanel.add(b_find);
  43. southPanel.add(b_reclaim);
  44. southPanel.add(b_lend);
  45. southPanel.add(b_clear);
  46. southPanel.add(b_newBook);
  47. southPanel.add(b_save);
  48. southPanel.add(b_load);
  49.  
  50. l_isbn = new JLabel("isbn:");
  51. l_title = new JLabel("title:");
  52. l_reclaim = new JLabel("return:");
  53. l_lend = new JLabel("lend:");
  54. l_storage = new JLabel("storage:");
  55.  
  56. tf_isbn = new JTextField(12);
  57. tf_title = new JTextField(12);
  58. tf_reclaim = new JTextField(12);
  59. tf_lend = new JTextField(12);
  60. tf_storage = new JTextField(12);
  61.  
  62. centerPanel.add(l_isbn);
  63. centerPanel.add(tf_isbn);
  64. centerPanel.add(l_title);
  65. centerPanel.add(tf_title);
  66. centerPanel.add(l_reclaim);
  67. centerPanel.add(tf_reclaim);
  68. centerPanel.add(l_lend);
  69. centerPanel.add(tf_lend);
  70. centerPanel.add(l_storage);
  71. centerPanel.add(tf_storage);
  72.  
  73. frame.setContentPane(background);
  74. frame.pack();
  75. frame.setVisible(true);
  76.  
  77. background.add(centerPanel,BorderLayout.CENTER);
  78. background.add(southPanel,BorderLayout.SOUTH);
  79.  
  80. SaveHandler SL = new SaveHandler();
  81. ClearHandler cl = new ClearHandler();
  82. FindHandler fh = new FindHandler();
  83. LendHandler LE = new LendHandler();
  84. ReclaimHandler RE = new ReclaimHandler();
  85. AddHandler AH = new AddHandler();
  86.  
  87. this.b_save.addActionListener(SL);
  88. this.b_clear.addActionListener(cl);
  89. this.b_lend.addActionListener(LE);
  90. this.b_reclaim.addActionListener(RE);
  91. this.b_find.addActionListener(fh);
  92. this.b_newBook.addActionListener(AH);
  93. this.libraryN = libraryN;
  94.  
  95. }
  96. private class ClearHandler implements ActionListener{
  97. public void actionPerformed(ActionEvent ae){
  98. System.out.println("clear");
  99. tf_isbn.setText("");
  100. tf_title.setText("");
  101. tf_storage.setText("");
  102. tf_lend.setText("");
  103. tf_reclaim.setText("");
  104. }
  105. }
  106. private class SaveHandler implements ActionListener{
  107. public void actionPerformed(ActionEvent ae){
  108. System.out.println("save");
  109. }
  110.  
  111. }
  112. private class FindHandler implements ActionListener{
  113. public void actionPerformed(ActionEvent ae){
  114. System.out.println("find");
  115. }
  116. }
  117. private class LendHandler implements ActionListener{
  118. public void actionPerformed(ActionEvent ae){
  119. System.out.println("lend");
  120.  
  121. }
  122. }
  123. private class ReclaimHandler implements ActionListener{
  124. public void actionPerformed(ActionEvent ae){
  125. System.out.println("reclaim");
  126. }
  127. }
  128. private class AddHandler implements ActionListener{
  129. public void actionPerformed(ActionEvent ae){
  130. System.out.println("add");
  131. }
  132. }
  133.  
  134.  
  135. }
Add Comment
Please, Sign In to add comment