private void btnSearchTitleActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSearchTitleActionPerformed String title = txtSearchTitle.getText(); Node n = bst.find(m1.getISBN(title)); jLabel15.setText(n.getElement().getBookTitle()); jLabel16.setText(n.getElement().getAuthorFirstName()); jLabel23.setText(n.getElement().getAuthorLastName()); jLabel17.setText(Integer.toString(n.getElement().getISBN())); } // GEN-LAST:event_btnSearchTitleActionPerformed
private void btnAddActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnAddActionPerformed int x = 1; int isbn = Integer.parseInt(txtISBN.getText()); if (txtBookTitle.getText().length() == 0 || txtAuthor.getText().length() == 0 || txtISBN.getText().length() == 0) { JOptionPane.showMessageDialog( null, "Textfields cannot be empty. Please complete Book Title, Author and ISBN", "Error", JOptionPane.ERROR_MESSAGE); } else if (!txtISBN.getText().matches("[-+]?\\d+(\\.\\d+)?")) { JOptionPane.showMessageDialog( null, "ISBN can only contain numbers", "Error", JOptionPane.ERROR_MESSAGE); x = 0; } if (txtBookTitle.getText().length() != 0 && txtAuthor.getText().length() != 0 && txtISBN.getText().length() != 0 && x == 1) { String authorname = txtAuthor.getText(); String surname = txtSurname.getText(); String title = txtBookTitle.getText(); int bisbn = Integer.parseInt(txtISBN.getText()); Book b1 = new Book(bisbn, title, authorname, surname); m1.insertBookMap(title, bisbn); bst.add(b1); JOptionPane.showMessageDialog(null, txtBookTitle.getText() + " has added"); txtBookTitle.setText(""); txtAuthor.setText(""); txtISBN.setText(""); txtSurname.setText(""); } } // GEN-LAST:event_btnAddActionPerformed