drawing a rectangle inside a label with a picture

Hi everyone,i want to know how you can draw a rectangle inside a label that have an iconimagethanks in advance,kimos
[144 byte] By [Kimosa] at [2007-11-26 13:53:54]
# 1

It depends if you want it only to show on the GUI or really change the image inside the IconImage.

If you just want it to show in your GUI, extend JLabel and implement paintComponent to draw a rectangle on top.

JLabel label = new JLabel() {

protected void paintComponent(Graphics g) {

super.paintComponent(g);

g.drawRect(x, y, width, height);

}

};

Rodney_McKaya at 2007-7-8 1:32:12 > top of Java-index,Security,Cryptography...
# 2
its working, but this way i can not change the rectangle position and width and hight, now i draw it when the program start and i cant change it,is there a way to do it, in such a way that i can call paintcomonent to redraw it again with the new parms?
Kimosa at 2007-7-8 1:32:12 > top of Java-index,Security,Cryptography...
# 3
You don't call paintComponent, it's called every time the component is being redrawn.Just set another width and height and call label.repaint()
Rodney_McKaya at 2007-7-8 1:32:12 > top of Java-index,Security,Cryptography...
# 4
thanksss alot :) cheers
Kimosa at 2007-7-8 1:32:12 > top of Java-index,Security,Cryptography...