X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderGroup.java;h=df3b74a0bdaaab9d9da355dd4943f7ba0e94f02f;hp=3e86fba9d0a7a3677a73323ea9d44c4e35a86629;hb=c499d79f13535082dd25c7ee46e897d3372c4299;hpb=81acd363d9b0af424d462e9d2e6a07b160e7af3b diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java index 3e86fba..df3b74a 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderGroup.java @@ -29,6 +29,8 @@ public class GuiReaderGroup extends JPanel { private static final long serialVersionUID = 1L; private BookActionListener action; private Color backgroundColor; + private Color backgroundColorDef; + private Color backgroundColorDefPane; private GuiReader reader; private List infos; private List books; @@ -51,15 +53,13 @@ public class GuiReaderGroup extends JPanel { */ 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)); @@ -113,6 +113,43 @@ public class GuiReaderGroup extends JPanel { }); } + /** + * Note: this class supports NULL as a background color, which will revert + * it to its default state. + *

+ * Note: this class' implementation will also set the main pane background + * color at the same time. + *

+ * Sets the background color of this component. The background color is used + * only if the component is opaque, and only by subclasses of + * JComponent or ComponentUI implementations. + * Direct subclasses of JComponent must override + * paintComponent to honor this property. + *

+ * It is up to the look and feel to honor this property, some may choose to + * ignore it. + * + * @param bg + * the desired background Color + * @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)