/**
* 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();
+ }
}
}
addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent e) {
- if (e.isPopupTrigger()) {
+ if (isEnabled() && e.isPopupTrigger()) {
popup(e);
}
}
@Override
public void mousePressed(MouseEvent e) {
- if (e.isPopupTrigger()) {
+ if (isEnabled() && e.isPopupTrigger()) {
popup(e);
}
}
}
lastClick = now;
+ e.consume();
}
}
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();
}
}
listener.select((GuiReaderBook.this));
listener.popupRequested(GuiReaderBook.this, e);
}
+
+ e.consume();
}
});
}
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.
*