public void addBook() {

		// User inputs: isbn, title, mainAuthors, otherAuthors,
		// publisher, year, subjects
		JTextField isbnField = new JTextField(15);
		JTextField titleField = new JTextField(20);
		JTextField mainAuthorField = new JTextField(20);
		JTextField otherAuthorsField = new JTextField(90);
		JTextField publisherField = new JTextField(10);
		JTextField yearField = new JTextField(10);
		JTextField subjectsField = new JTextField(90);

		Vector<String> list = getSubjectList();
		JList subjectsList = new JList(list);
		subjectsList.setVisibleRowCount(5);
		subjectsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		subjectsList.setLayoutOrientation(JList.VERTICAL_WRAP);

		JComponent[] inputs = new JComponent[] { 
				new JLabel("isbn:"), isbnField, 
				new JLabel("Title:"), titleField,
				new JLabel("Main author:"), mainAuthorField,
				new JLabel("Other authors:"), otherAuthorsField,
				new JLabel("Publisher:"), publisherField, 
				new JLabel("Year:"), yearField, 
				new JLabel("Subjects:"), subjectsList,
				new JLabel("Add new subjects:"), subjectsField 
				};

		int result = JOptionPane.showConfirmDialog(null, inputs,
				"Enter book info", JOptionPane.OK_CANCEL_OPTION,
				JOptionPane.WARNING_MESSAGE);

		if (result == JOptionPane.OK_OPTION) {
			String isbn = isbnField.getText();
			String title = titleField.getText();
			String mainAuthor = mainAuthorField.getText();
			String[] otherAuthors = otherAuthorsField.getText().split(",");
			String publisher = publisherField.getText();
			int year = Integer.parseInt(yearField.getText());
			String callNumber = randomString() + " " + randomString() + " "
					+ Integer.toString(year);
			
			// Retrieve list of subjects for book
			Vector<String> subjects = new Vector<String>(5,1);
			for (int i = 0; i < subjectsList.getSelectedValues().length; i++) {
				subjects.addElement(subjectsList.getSelectedValues()[i].toString());
			}
			String[] newSubjects = subjectsField.getText().split(",");
			Collections.addAll(subjects, newSubjects);
			try {

				// Insert new book into Book table
				PreparedStatement ps = Library.con
						.prepareStatement("INSERT INTO book (callNumber, isbn, title, mainAuthor, publisher, year) VALUES (?,?,?,?,?,?)");
				ps.setString(1, callNumber);
				ps.setString(2, isbn);
				ps.setString(3, title);
				ps.setString(4, mainAuthor);
				ps.setString(5, publisher);
				ps.setInt(6, year);

				ps.executeUpdate();
				Library.con.commit();

				// Show Book table
				Statement stmt = Library.con.createStatement();
				ResultSet rs = stmt.executeQuery("SELECT * FROM Book");
				LibraryGUI.showTable(rs, "addBookButton");

				rs.close();
				ps.close();

			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

			try {
				for (int i = 0; i < otherAuthors.length; i++) {

					// Add other entered authors into hasAuthor table
					PreparedStatement ps = Library.con
							.prepareStatement("INSERT INTO hasAuthor VALUES (?,?)");
					ps.setString(1, callNumber);
					ps.setString(2, otherAuthors[i]);

					ps.executeUpdate();
					Library.con.commit();
					ps.close();
				}

			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

			try {
				for (int i = 0; i < subjects.size(); i++) {

					// Add subjects into hasSubjects table
					PreparedStatement ps = Library.con
							.prepareStatement("INSERT INTO hasSubject VALUES (?,?)");
					ps.setString(1, callNumber);
					ps.setString(2, subjects.get(i));

					ps.executeUpdate();
					Library.con.commit();
					ps.close();
				}

			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}