protected void saveGenre() { // get the genre info from gui String genre = genreTextField.getText(); Genres tempGenre = null; if (updateMode) { tempGenre = previousGenre; tempGenre.setGenre(genre); } else { tempGenre = new Genres(genre); } try { // save to the database if (updateMode) { genresDAO.updateGenres(tempGenre); } else { genresDAO.addGenres(tempGenre); } // close dialog setVisible(false); dispose(); // refresh gui list ClientWindow.refreshGenresView(); // show success message JOptionPane.showMessageDialog( null, "The Genre saved succesfully.", "Info", JOptionPane.INFORMATION_MESSAGE); } catch (SQLException exc) { JOptionPane.showMessageDialog( null, exc.getMessage(), "SQLException!", JOptionPane.ERROR_MESSAGE); exc.printStackTrace(); } catch (Exception exc) { JOptionPane.showMessageDialog( null, "Something went wrong!\n" + exc, "Error!", JOptionPane.ERROR_MESSAGE); exc.printStackTrace(); } }
private void populateGui(Genres theGenre) { genreTextField.setText(theGenre.getGenre()); }