/**
* The book current selection state.
+ * <p>
+ * Setting this value to true can cause a "select" action to occur if the
+ * previous state was "unselected".
*
* @param selected
* TRUE if it is selected
if (this.selected != selected) {
this.selected = selected;
repaint();
+
+ if (selected) {
+ select();
+ }
}
}
}
private void click(boolean doubleClick) {
- for (BookActionListener listener : listeners) {
- if (doubleClick) {
- listener.action(GuiReaderBook.this);
- } else {
- listener.select(GuiReaderBook.this);
- }
+ if (doubleClick) {
+ action();
+ } else {
+ select();
}
}
listeners.add(listener);
}
+ /**
+ * Cause an action to occur on this {@link GuiReaderBook}.
+ */
+ public void action() {
+ for (BookActionListener listener : listeners) {
+ listener.action(GuiReaderBook.this);
+ }
+ }
+
+ /**
+ * Cause a select event on this {@link GuiReaderBook}.
+ */
+ private void select() {
+ for (BookActionListener listener : listeners) {
+ listener.select(GuiReaderBook.this);
+ }
+ }
+
/**
* The information about the book represented by this item.
*