/** Construct a search using the advanced search fields and invoke a search. */ private void buildSearchFromForms() { Book searchBook = new Book(); boolean anythingSearched = false; /* * Get Title from field */ if (!titleField.getText().isEmpty()) { anythingSearched = true; searchBook.title = titleField.getText(); } /* * Get Author from field */ if (!authorField.getText().isEmpty()) { anythingSearched = true; searchBook.author = authorField.getText(); } /* * Get Keywords from field */ if (!keywordField.getText().isEmpty()) { anythingSearched = true; searchBook.description = keywordField.getText(); } /* * Get ISBN from field */ if (!isbnField.getText().isEmpty()) { anythingSearched = true; searchBook.ISBN = Integer.parseInt(isbnField.getText()); } /* * If all the fields were blank, don't search */ if (!anythingSearched) { JOptionPane.showMessageDialog( null, "Nothing Searched", "No Values", JOptionPane.INFORMATION_MESSAGE); } else { try { /* * Perform a search */ ArrayList<Book> books = Controller.searchForBook(searchBook); /* * Show the results */ PanelsManager.newSearchResults(books); } catch (Exception e) { /* * Print error message if error occurs */ e.printStackTrace(); PanelsManager.displayError("Book Search failed\n" + "Contact tech support"); } } }