Compontens over image...

Hi, guys.

I had a JFrame in which I put a background image using the paint(Graphics g) method.

When I put a JLabel (called lblNote in code bellow) over the image , the image background is lost by the JLabel background, that is gray.

My intention is that the JLabel background become transparent (just the letters appears over the JFrame background image).

The paint method code of JFrame:

publicvoid paint(Graphics g){

super.paint(g);

int x = (this.getWidth() - planoDeFundo.getWidth(null)) / 2;

int y = (this.getHeight() - planoDeFundo.getHeight(null)) / 2;

g.drawImage(planoDeFundo, x, y,this );

lblNote.repaint();

}

If I put lblNote.paint(g) instead lblNote.repaint() works fine, but the JLabel is rendered in (x, y) = (0,0) coordinates on JFrame (left top). I tried put the coordinates after that by the setLocation method, but the JLabel background turns gray again. :(

Someone can help me?

Thanks in advance!

PS: sorry for my poor english.

[1333 byte] By [reolcaa] at [2007-11-27 8:48:09]
# 1
use setOpaque(false) on the JLabel or any other components to remove the backgroundICE
icewalker2ga at 2007-7-12 20:54:36 > top of Java-index,Desktop,Core GUI APIs...
# 2
You don't override the paint() method of a JFrame. Custom painting is done by overriding the paintComponent() method of a JComponent or JPanel. Search the forum using "background image" and you will find other postings on this topic with various solutions.
camickra at 2007-7-12 20:54:36 > top of Java-index,Desktop,Core GUI APIs...
# 3

icewalker2g, I already tried that, but not works for me.

Thanks.

--

Oh my god! I tried all kind of search, unless the obvious: just "background image". Thanks. This post help-me. I will give to you the ducks.

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=5127112

Thanks.

Message was edited by:

reolca

reolcaa at 2007-7-12 20:54:36 > top of Java-index,Desktop,Core GUI APIs...