> How do I put 5 buttons on top of an image?
Mixing graphics with Components is not really a good idea in Java
(equivalent to Q8.6 of the FAQ). Consider another approach, like drawing
some kind of buttons with the 2D API and handling your own mouse events.
If you really want buttons, then start with learning the layout
managers. You are apparently missing the basics: Getting buttons on a
JPanel where you want them. Getting a background image is the second,
not the first step, and you already fail the first one.
> If I set button constraints to Rectangles the image is greyed out to
> the bottom right of the lowest button. Aint that sad.
No, you mixed up the painting. Please spend some time and make yourself
familiar with the Swing architecture and the AWT/Swing painting model,
particularly the handling of transparency. Sun's TSC articles about this
subjects are a good start.
> Over in the Sun forum, in 2004,
> [http://forum.java.sun.com/thread.jspa?forumID=5&threadID=494487
[quoted text clipped - 3 lines]
>
> This precisely does NOT answer the question.
Well, then you might want to work on your asking style. Do you think it
is easy to make sense of your sentence like:
> Because the image takes time to load up when it loads up the image
loads on top of the buttons rather than being below.
> Evidently the java gods never envisioned buttons ON TOP of the image.
> .. Or is there a way???
It is a piece of cake - *if you know the basics*
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
gbruno schrieb:
> How do I put 5 buttons on top of an image?
Not at all.
[...]
> Evidently the java gods never envisioned buttons ON TOP of the image.
Evidently you never envisioned to start learning the basics - SCNR.
> .. Or is there a way???
What you want (or what I think you want) is a panel that is able to
display an image in the background:
class IconPanel extends JPanel {
private Icon icon;
public void setIcon( Icon icon ) {
this.icon = icon;
repaint();
}
public void paintComponent( Graphics g ) {
super.paintComponent(g);
if ( icon != null )
icon.paintIcon( this, g, 0, 0 );
}
}
Bye
Michael
gbruno - 09 Jun 2005 02:35 GMT
Yes, IconPanel does look like the solution.
Thanks for prompt replies, I can handle the abuse if it means such
prompt replies. (Ask in the afternoon in Sydney, get the answer in the
next morning,)
btw its conflicting to get abused by 2 respondents who offer mutually
exclusive solutions. One lot of abuse must be right up itself.
gbruno - 09 Jun 2005 03:38 GMT
yes IconPanel works.
Although I'm from Wellington, and spent yers drinking in the Gluepot in
Ponsonby Road, I promise not to throw the phone at you.