Draw a line over a JLabel

Hello,

Does anyone know if there is a way to draw a line over a JLabel. The scenario is that I have a Jpanel that uses a Gridbaglayout and has an array of JLabels(to display images). I have the need to connect labels and to have the line draw over any labels that it intersects.

I know this can be done if you use the same graphics context to draw the image and the line, but since I need to use JLabels and the graphics context that draws the line is a JPanel's, I have a problem.

Is there a way to draw a line over a JLabel?

Thanks

lon

[576 byte] By [lon22a] at [2007-11-27 7:03:13]
# 1

Easiest thing to do would be to override paintChildren like

public void paintChildren(Graphics g) {

super.paintChildren(g);

//paint your line here

}

That should do what you want - paint the children first and then draw over them

tjacobs01a at 2007-7-12 18:54:24 > top of Java-index,Security,Cryptography...
# 2
Thank you tjacobs01. Drawing the line in the paintChildren method of my JPanel instead of it's paintComponent method did the trick.
lon22a at 2007-7-12 18:54:24 > top of Java-index,Security,Cryptography...