Example #1
0
 public void actionPerformed(ActionEvent e) {
   // This if statement prevents the the program from searching the records when no parameters
   // had been entered( because that would be pointless)
   if (((searchTextfield[0].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[0].getText().equalsIgnoreCase("")))
       && ((searchTextfield[1].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[1].getText().equalsIgnoreCase("")))
       && ((searchTextfield[2].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[2].getText().equalsIgnoreCase("")))
       && ((searchTextfield[3].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[3].getText().equalsIgnoreCase("")))
       && ((searchTextfield[4].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[4].getText().equalsIgnoreCase("")))
       && ((searchTextfield[5].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[5].getText().equalsIgnoreCase("")))
       && ((searchTextfield[6].getText().equalsIgnoreCase("enter Search Parameter"))
           || (searchTextfield[6].getText().equalsIgnoreCase("")))) {
   }
   // If a search parameters has been entered, then the records will be searched, reloaded back
   // to the GUI, and the buttons will be disabled.
   // The buttons are disabled because it is one of the limitations of the program
   else {
     Classes.search();
     Classes.makeSearchArrayIndexesLookNicer();
     reloadArrayValuesToGUI();
     Classes.EnableSortButtons(false);
   }
 }
Example #2
0
 public void actionPerformed(ActionEvent e) {
   // The searchTextfields will be reset
   for (int i = 0; i < 7; i++) {
     searchTextfield[i].setText("enter Search Parameter");
   }
   // arrayIndexes will be reset
   Classes.resetArrayIndexes();
   reloadArrayValuesToGUI();
   // the sorting buttons will be enabled again
   Classes.EnableSortButtons(true);
 }
Example #3
0
  public GUI() {
    // ===============================================loads data from savefiles (textfiles)
    Classes.LoadData();
    // =========================================== resets the arrayIndexes array so that the the GUI
    // will first show the records according to IDNumber
    Classes.resetArrayIndexes();
    // =========================================== Redeclaring GUI Components (this is part of GUI
    // Syntax for some reason)
    // =========================================== This also gives text to those GUI Components
    search = new JButton("search");
    clearSearchParameters = new JButton("clear Parameters");
    help = new JButton("Help");
    resetDatabase = new JButton("Reset Database");
    messageToUser = new JLabel("");
    emptyLabel = new JLabel[3];
    newRecordButton = new JButton(" New Record");
    editRecordButton = new JButton(" Edit Record");
    deleteRecordButton = new JButton("Delete Record");

    searchTextfield = new JTextField[7];
    fieldNames = new JButton[7];
    textfield = new JTextField[6][100];
    indexes = new JLabel[100];
    RecordsFieldButtons = new JPanel();
    scrollPane = new JScrollPane();

    emptyLabel[0] = new JLabel("");
    emptyLabel[1] = new JLabel("");
    emptyLabel[2] = new JLabel("");
    fieldNames[0] = new JButton("ID#");
    fieldNames[1] = new JButton("Movie Name");
    fieldNames[2] = new JButton("Movie Length");
    fieldNames[3] = new JButton("Movie Director");
    fieldNames[4] = new JButton("Movie Rating");
    fieldNames[5] = new JButton("Movie Release Year");
    fieldNames[6] = new JButton("Movie Review" + "Rating");
    // =========================================== All the searchTextfields will be preset to the
    // text "enter Search Parameter"
    for (int x = 0; x < 7; x++) {
      searchTextfield[x] = new JTextField("enter Search Parameter");
    }
    // =========================================== This for loop attaches the correct array value to
    // the GUI Components
    for (int x = 0; x < 7; x++) {
      for (int y = 0; y < 100; y++) {
        switch (x) {
          case 0:
            // =============================== This checks if the value of IDNumber[xxx] is blank
            // (which is noted by a -1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (IDNumber[arrayIndexes[y]] == -1) {
              indexes[y] = new JLabel("");
            } else {
              indexes[y] = new JLabel(Integer.toString(IDNumber[arrayIndexes[y]]));
            }
            break;
          case 1:
            // =============================== This checks if the value of movieName[xxx] is blank
            // (which is noted by a "null")
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieName[arrayIndexes[y]].equals("null") == true) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] = new JTextField(movieName[arrayIndexes[y]]);
            }
            break;
          case 2:
            // =============================== This checks if the value of movieLength[xxx] is blank
            // (which is noted by a -1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieLength[arrayIndexes[y]] == -1) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] =
                  new JTextField(Integer.toString(movieLength[arrayIndexes[y]]) + " minutes");
            }
            break;
          case 3:
            // =============================== This checks if the value of movieDirector[xxx] is
            // blank (which is noted by a "null")
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieDirector[arrayIndexes[y]].equals("null") == true) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] = new JTextField(movieDirector[arrayIndexes[y]]);
            }
            break;
          case 4:
            // =============================== This checks if the value of movieRating[xxx] is blank
            // (which is noted by a "null") or if it is unavailable "N/A"
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if ((movieRating[arrayIndexes[y]].equals("null") == true)
                || (movieRating[arrayIndexes[y]].equals("N/A") == true)) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] = new JTextField(movieRating[arrayIndexes[y]]);
            }
            break;
          case 5:
            // =============================== This checks if the value of movieReleaseYear[xxx] is
            // blank (which is noted by a -1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieReleaseYear[arrayIndexes[y]] == -1) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] =
                  new JTextField(Integer.toString(movieReleaseYear[arrayIndexes[y]]));
            }
            break;
          case 6:
            // =============================== This checks if the value of movieReviewRating[xxx] is
            // blank (which is noted by a -0.1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieReviewRating[arrayIndexes[y]] == -0.1) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] =
                  new JTextField(Double.toString(movieReviewRating[arrayIndexes[y]]));
            }
            break;
        }
        // =============================== This disables the ability for the all the textfields to
        // be edited.
        if ((x <= 6) && (x >= 1)) {
          textfield[x - 1][y].setEditable(false);
        }
      }
    }
    // ======================================= Makes the layout of the panel (gridlayout)
    RecordsFieldButtons.setLayout(new GridLayout(103, 7));
    // ======================================= adds the GUI components to the GUI
    RecordsFieldButtons.add(newRecordButton);
    RecordsFieldButtons.add(editRecordButton);
    RecordsFieldButtons.add(deleteRecordButton);
    // RecordsFieldButtons.add(messageToUser);
    // RecordsFieldButtons.add(emptyLabel[0]);
    // RecordsFieldButtons.add(emptyLabel[1]);
    // RecordsFieldButtons.add(emptyLabel[2]);
    RecordsFieldButtons.add(search);
    RecordsFieldButtons.add(clearSearchParameters);
    RecordsFieldButtons.add(resetDatabase);
    RecordsFieldButtons.add(help);

    // ======================================= places the searchTextfield onto the GUI
    for (int x = 0; x < 7; x++) {
      RecordsFieldButtons.add(searchTextfield[x]);
    }
    // ======================================= places the fieldnames onto the GUI. (the fieldnames
    // are also the buttons for sort)
    for (int x = 0; x < 7; x++) {
      // fieldNames[x].setLineWrap(true);
      RecordsFieldButtons.add(fieldNames[x]);
    }
    // ======================================= places the rest of the array values( textfields) onto
    // the GUI
    for (int y = 0; y < 100; y++) {
      for (int x = 0; x < 7; x++) {
        if (x == 0) {
          RecordsFieldButtons.add(indexes[y]);
        } else {
          RecordsFieldButtons.add(textfield[x - 1][y]);
        }
      }
    }
    // ======================================= changes the color of the fields names to orange
    // ======================================= the point of this is to give a separation between the
    // arrayvalues and the function buttons
    for (int i = 0; i < 7; i++) {
      fieldNames[i].setBackground(Color.ORANGE);
    }
    // ======================================= adds actions to all the GUI Components( if any)
    fieldNames[0].addActionListener(new whenUserClickIDNumberButton());
    fieldNames[1].addActionListener(new whenUserClickMovieNameButton());
    fieldNames[2].addActionListener(new whenUserClickMovieLengthButton());
    fieldNames[3].addActionListener(new whenUserClickMovieDirectorButton());
    fieldNames[4].addActionListener(new whenUserClickMovieRatingButton());
    fieldNames[5].addActionListener(new whenUserClickMovieReleaseYearButton());
    fieldNames[6].addActionListener(new whenUserClickMovieReviewButton());
    search.addActionListener(new whenUserClickSearchButton());
    clearSearchParameters.addActionListener(new whenUserClickClearParametersButton());
    help.addActionListener(new helpFunction());
    resetDatabase.addActionListener(new whenUserClicksResetDatabse());
    newRecordButton.addActionListener(new whenUserClicksNewButton());
    editRecordButton.addActionListener(new whenUserClicksEditButton());
    deleteRecordButton.addActionListener(new whenUserClicksDeleteButton());
    JFrame frame = new JFrame("Movie Database");
    frame.addWindowListener(new whenUserClicksXOnTheCornerOfWindow());
    frame.setResizable(true);
    frame.add(new JScrollPane(RecordsFieldButtons));
    frame.setSize(100, 100);
    frame.setVisible(true);
    frame.pack();
  }
Example #4
0
 public void actionPerformed(ActionEvent e) {
   Classes.ResetRecords();
   reloadArrayValuesToGUI();
 }
Example #5
0
 public void actionPerformed(ActionEvent e) {
   Classes.sortArray(movieReviewRating);
   reloadArrayValuesToGUI();
 }
Example #6
0
 public void actionPerformed(ActionEvent e) {
   Classes.sortArray(movieReleaseYear);
   reloadArrayValuesToGUI();
 }
Example #7
0
 public void actionPerformed(ActionEvent e) {
   Classes.sortArray(movieDirector);
   reloadArrayValuesToGUI();
 }
Example #8
0
 public void actionPerformed(ActionEvent e) {
   Classes.sortArray(IDNumber);
   reloadArrayValuesToGUI();
 }