+ /**
+ * Populate a list of authors as {@link JMenuItem}s into the given
+ * {@link JMenu}.
+ * <p>
+ * Each item will select the author when clicked.
+ *
+ * @param authors
+ * the parent {@link JMenuItem}
+ * @param names
+ * the authors' names
+ */
+ private void populateMenuAuthorList(JMenu authors, List<String> names) {
+ for (final String name : names) {
+ JMenuItem item = new JMenuItem(name == null ? "All"
+ : name.isEmpty() ? "[unknown]" : name);
+ item.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ removeBookPanes();
+ addBookPane(name, false);
+ refreshBooks();
+ }
+ });
+ authors.add(item);
+
+ if (name == null || name.isEmpty()) {
+ authors.addSeparator();
+ }
+ }
+ }
+