diff options
author | Florian Pritz <bluewind@xinu.at> | 2013-07-15 14:06:57 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2013-07-15 14:06:57 +0200 |
commit | f00fd63cd8a4252d85f04359956d5f79036f0eb2 (patch) | |
tree | 7561272fd22e7d1cc844c4f636bd68c5d2527083 /src/com/joshwalters/bookcatalog | |
parent | 8b12426328b9200acca352dba11263d0f51a3ba7 (diff) | |
download | BookCatalog-working.tar.gz BookCatalog-working.tar.xz |
Add field for defaul note when adding new booksworking
This allows the user to use the note feature to track in which shelf a
book is located without having to manually add the information to each
newly added book.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'src/com/joshwalters/bookcatalog')
-rw-r--r-- | src/com/joshwalters/bookcatalog/AddBook.java | 6 | ||||
-rw-r--r-- | src/com/joshwalters/bookcatalog/BookCatalog.java | 20 | ||||
-rw-r--r-- | src/com/joshwalters/bookcatalog/bookdatabase/BookDatabase.java | 6 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/com/joshwalters/bookcatalog/AddBook.java b/src/com/joshwalters/bookcatalog/AddBook.java index 05b227c..eab5879 100644 --- a/src/com/joshwalters/bookcatalog/AddBook.java +++ b/src/com/joshwalters/bookcatalog/AddBook.java @@ -48,6 +48,7 @@ class AddBook implements ActionListener { private ISBNLookup bookLookup = null; private BookDatabase bookDatabase = null; private JTable bookCatalogTable = null; + private JTextField notes = null; /** * Get the different objects needed for the class to function. @@ -57,10 +58,11 @@ class AddBook implements ActionListener { * @param bookCatalogTable */ public AddBook(BookDatabase bookDatabase, ISBNLookup bookLookup, - JTable bookCatalogTable) { + JTable bookCatalogTable, JTextField notes) { this.bookDatabase = bookDatabase; this.bookLookup = bookLookup; this.bookCatalogTable = bookCatalogTable; + this.notes = notes; } /** @@ -79,7 +81,7 @@ class AddBook implements ActionListener { .getAuthor(), bookLookup.getDate(), bookLookup .getDescription(), bookLookup.getISBN(), bookLookup .getPrice(), bookLookup.getPublisher(), bookLookup - .getSubject()); + .getSubject(), this.notes.getText()); // Play the beep sound to alert the user that the book was added to // the database. new PlayWavSoundFile("data/sounds/beep.wav").start(); diff --git a/src/com/joshwalters/bookcatalog/BookCatalog.java b/src/com/joshwalters/bookcatalog/BookCatalog.java index 17aed55..8a1bf77 100644 --- a/src/com/joshwalters/bookcatalog/BookCatalog.java +++ b/src/com/joshwalters/bookcatalog/BookCatalog.java @@ -73,6 +73,10 @@ public class BookCatalog { */ private JTextField addBookField; /** + * Allows user to add book including a comment to catalog. + */ + private JTextField addBookNotesField; + /** * Displays the book catalog. */ // private JTable bookCatalogTable; @@ -183,6 +187,20 @@ public class BookCatalog { gridConstraints.fill = GridBagConstraints.REMAINDER; gridConstraints.anchor = GridBagConstraints.WEST; frame.add(addBookField, gridConstraints); + // The add book notes label + JLabel addBookNotesLabel = new JLabel("New Book Notes"); + gridConstraints.gridx = 5; + gridConstraints.gridy = 0; + frame.add(addBookNotesLabel, gridConstraints); + // The add book notes field + addBookNotesField = new JTextField(FIELD_WIDTH); + gridConstraints.gridx = 6; + gridConstraints.gridy = 0; + gridConstraints.insets.top = 10; + gridConstraints.insets.left = 10; + gridConstraints.fill = GridBagConstraints.REMAINDER; + gridConstraints.anchor = GridBagConstraints.WEST; + frame.add(addBookNotesField, gridConstraints); // Change the grid constraints back to their the normal state. gridConstraints.fill = GridBagConstraints.NONE; gridConstraints.anchor = GridBagConstraints.CENTER; @@ -322,7 +340,7 @@ public class BookCatalog { frame.add(deleteBookButton, gridConstraints); // Listens for add book input. addBookField.addActionListener(new AddBook(bookDatabase, bookLookup, - bookCatalogTable)); + bookCatalogTable, addBookNotesField)); // Listens for delete book button press. deleteBookButton.addActionListener(new DeleteBook(bookDatabase, titleField, authorField, dateField, descriptionArea, ISBNField, diff --git a/src/com/joshwalters/bookcatalog/bookdatabase/BookDatabase.java b/src/com/joshwalters/bookcatalog/bookdatabase/BookDatabase.java index 9f06aba..352adf7 100644 --- a/src/com/joshwalters/bookcatalog/bookdatabase/BookDatabase.java +++ b/src/com/joshwalters/bookcatalog/bookdatabase/BookDatabase.java @@ -211,12 +211,13 @@ public class BookDatabase { * @param Price
* @param Publisher
* @param Subject
+ * @param Notes
* @throws SQLException
* @throws BookAlreadyInDatabase
*/
public void insertBook(String Title, String Author, String Date,
String Description, String ISBN, String Price, String Publisher,
- String Subject) throws SQLException, BookAlreadyInDatabase {
+ String Subject, String Notes) throws SQLException, BookAlreadyInDatabase {
// Check to see if the book is in the database
if (!isBookInDatabase(ISBN)) {
// The SQL statement
@@ -231,8 +232,7 @@ public class BookDatabase { preparedStatement.setString(6, Price);
preparedStatement.setString(7, Publisher);
preparedStatement.setString(8, Subject);
- // Set the notes for the book blank by default.
- preparedStatement.setString(9, "");
+ preparedStatement.setString(9, Notes);
if (preparedStatement.execute()) {
resultSet = statement.getResultSet();
if (resultSet != null) {
|