> Hi all,
>
> I'm coding a graphical interface for small screen touchscreen PC composed of
> menus and submenus. As the look of it must be fancy, there is a background
> image.
[...]
> getClass().getClassLoader().getResource(
> "skins/tst/gprs.png"));
this.class.getResource("/skins/tst/gprs.png");
> Two questions :
> - Is there another simpler design to avoid LayeredPane + JPanel (this is to
> repaint the background after some elements of the status bar change) ?
Subclass JPanel and override the paintComponent() method (and override
isOpaque() to always return true, but that is a longer story). In
paintComponent() paint the background image. Use instances of this
subclassed JPanel as your container.
If you need the background image stretch not only over a particular
JPanel, but over the entire size of a window, you need to subclass the
particular JFrame or JDialog class instead of JPanel and do a similar
change.
> - There is a small border at the top of the window where the LayeredPane is
> not visible, so there is a small stipe at the top of the window not colored
> by the layered pane. I tried to add an empty border to the JPane, put the
> LayeredFrame at the north, but the stripe is still there. Do you see a
> workaround ?
You need to find out who owns that space. The enclosing container or the
enclosed component. Depending on this you have to figure out why it is
there. E.g. check the insets.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
Tobias - 16 Feb 2005 11:32 GMT
Thanks for your answer.
>> Two questions :
>> - Is there another simpler design to avoid LayeredPane + JPanel (this is
[quoted text clipped - 9 lines]
> particular JFrame or JDialog class instead of JPanel and do a similar
> change.
If I do this, the look and feel styles that I could use with the whole app
wouldn't have effects on the background, or am I getting something wrong ?
Because the UI paintComponent would be overridden by this custom one,
would'nt it ?
In fact, what we are looking for is the possibility to change the background
image by defining another LnF. But the status bar always need to be black
and transparent above the background image in the content pane. And I want
to avoid the use of the glass pane...
Tobias