Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. /*
  2. * File: FacePamphlet.java
  3. * -----------------------
  4. * When it is finished, this program will implement a basic social network
  5. * management system.
  6. */
  7.  
  8. import acm.program.*;
  9. import acm.graphics.*;
  10. import acm.util.*;
  11.  
  12. import java.awt.event.*;
  13.  
  14. import javax.swing.*;
  15.  
  16. public class FacePamphlet extends Program implements FacePamphletConstants, ActionListener {
  17.  
  18. private JTextField nameBar;
  19. private JTextField statusBar;
  20. private JTextField pictureBar;
  21. private JTextField friendBar;
  22.  
  23. /**
  24. * This method has the responsibility for initializing the
  25. * interactors in the application, and taking care of any other
  26. * initialization that needs to be performed.
  27. */
  28. public void init() {
  29.  
  30. /*Adds label for user to know what to input*/
  31. add (new JLabel("Name"), NORTH);
  32.  
  33. /*Adds space for user to input Name*/
  34. nameBar = new JTextField(TEXT_FIELD_SIZE);
  35. add (nameBar, NORTH);
  36. nameBar.addActionListener(this);
  37.  
  38. /*Adds Add Button*/
  39. add (new JButton("Add"), NORTH);
  40.  
  41. /*Adds Delete Button*/
  42. add (new JButton("Delete"), NORTH);
  43.  
  44. /*Adds Lookup Button*/
  45. add (new JButton("Lookup"), NORTH);
  46.  
  47. /*Adds space for user to input status*/
  48. statusBar = new JTextField(TEXT_FIELD_SIZE);
  49. statusBar.setActionCommand("Change Status"); //Enables enter key
  50. add (statusBar, WEST);
  51. statusBar.addActionListener(this);
  52.  
  53. /*Adds button to input new status*/
  54. add (new JButton("Change Status"), WEST);
  55.  
  56. /*Adds empty space*/
  57. add (new JLabel(EMPTY_LABEL_TEXT), WEST);
  58.  
  59. /*Adds space for user to input picture file*/
  60. pictureBar = new JTextField(TEXT_FIELD_SIZE);
  61. statusBar.setActionCommand("Change Picture"); //Enables enter key
  62. add (pictureBar, WEST);
  63. pictureBar.addActionListener(this);
  64.  
  65. /*Adds button to select a new picture.*/
  66. add (new JButton("Change Picture"), WEST);
  67.  
  68. /*Adds empty space*/
  69. add (new JLabel(EMPTY_LABEL_TEXT), WEST);
  70.  
  71. /*Adds space for user to input a Friend's name*/
  72. friendBar = new JTextField(TEXT_FIELD_SIZE);
  73. add (friendBar, WEST);
  74. friendBar.addActionListener(this);
  75.  
  76. /*Adds button to add friend.*/
  77. add (new JButton("Add Friend"), WEST);
  78.  
  79. addActionListeners();
  80. }
  81.  
  82. /**
  83. * This class is responsible for detecting when the buttons are
  84. * clicked or interactors are used, so you will have to add code
  85. * to respond to these actions.
  86. */
  87. public void actionPerformed(ActionEvent e) {
  88. //String cmd = e.getActionCommand();
  89. //Switch
  90. /*Enables the Enter Key*/
  91. // if (e.getSource() == Add) {
  92. // case "Add": {
  93. //// String query = searchBar.getText();
  94. //// if(database.findEntry(query) != null){//if name exists in database:
  95. //// graph.addEntry(database.findEntry(query));
  96. //// }
  97. // case "Delete":
  98. // case "Lookup":
  99. // case "Change Status":
  100. // case "Change Picture":
  101. // case "Add Friend":
  102. // case
  103. // } else if (cmd.equals("Delete")) {
  104. // //graph.clear();
  105. // /*Clears the arrayList of NameSurferEntry(s) in the graph object*/
  106. // } else if (cmd.equals("Lookup")) {
  107. //
  108. // } else if (cmd.equals("Change Status")) {
  109. //
  110. // } else if (cmd.equals("Change Picture")) {
  111. //
  112. // } else if (cmd.equals("Add Friend")) {
  113. //
  114. // }
  115. // }
  116.  
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement