import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
private static final long serialVersionUID = 1L;
private BookActionListener action;
private Color backgroundColor;
+ private Color backgroundColorDef;
+ private Color backgroundColorDefPane;
private GuiReader reader;
private List<GuiReaderBookInfo> infos;
private List<GuiReaderBook> books;
*/
public GuiReaderGroup(GuiReader reader, String title, Color backgroundColor) {
this.reader = reader;
- this.backgroundColor = backgroundColor;
this.pane = new JPanel();
-
pane.setLayout(new WrapLayout(WrapLayout.LEADING, 5, 5));
- if (backgroundColor != null) {
- pane.setBackground(backgroundColor);
- setBackground(backgroundColor);
- }
+
+ this.backgroundColorDef = getBackground();
+ this.backgroundColorDefPane = pane.getBackground();
+ setBackground(backgroundColor);
setLayout(new BorderLayout(0, 10));
});
}
+ /**
+ * Note: this class supports NULL as a background color, which will revert
+ * it to its default state.
+ * <p>
+ * Note: this class' implementation will also set the main pane background
+ * color at the same time.
+ * <p>
+ * Sets the background color of this component. The background color is used
+ * only if the component is opaque, and only by subclasses of
+ * <code>JComponent</code> or <code>ComponentUI</code> implementations.
+ * Direct subclasses of <code>JComponent</code> must override
+ * <code>paintComponent</code> to honor this property.
+ * <p>
+ * It is up to the look and feel to honor this property, some may choose to
+ * ignore it.
+ *
+ * @param bg
+ * the desired background <code>Color</code>
+ * @see java.awt.Component#getBackground
+ * @see #setOpaque
+ *
+ * @beaninfo preferred: true bound: true attribute: visualUpdate true
+ * description: The background color of the component.
+ */
+ @Override
+ public void setBackground(Color backgroundColor) {
+ Color cme = backgroundColor == null ? backgroundColorDef
+ : backgroundColor;
+ Color cpane = backgroundColor == null ? backgroundColorDefPane
+ : backgroundColor;
+
+ if (pane != null) { // can happen at theme setup time
+ pane.setBackground(cpane);
+ }
+ super.setBackground(cme);
+ }
+
/**
* The title of this group (can be NULL for "no title", an empty
* {@link String} will trigger a default title for empty groups)
if (infos != null) {
for (GuiReaderBookInfo info : infos) {
boolean isCached = false;
- if (info.getMeta() != null) {
+ if (info.getMeta() != null && info.getMeta().getLuid() != null) {
isCached = reader.isCached(info.getMeta().getLuid());
}
e.consume();
}
}
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+
+ Rectangle clip = g.getClipBounds();
+ if (clip.getWidth() <= 0 || clip.getHeight() <= 0) {
+ return;
+ }
+
+ if (!isEnabled()) {
+ g.setColor(new Color(128, 128, 128, 128));
+ g.fillRect(clip.x, clip.y, clip.width, clip.height);
+ }
+ }
}