java - draw a rectangle over an image -
i have tried code below drawing rectangle on image(jlabel) not drawing. please solve this.
protected void paintcomponent(graphics g) { this.paintcomponent(g); g2 = (graphics2d) g; g.drawrect(n,n1,40,40); } private void jlabel1mouseclicked(java.awt.event.mouseevent evt) { // todo add handling code here: k=0; f=jlabel1.getmouseposition(); n=f.x; n1=f.y; n=n+p/2; n1=n1+(q/2-25); repaint(n,n1,40,40); }
you have infinite recursion there, , stack overflow. this:
this.paintcomponent(g)
should instead:
super.paintcomponent(g);
Comments
Post a Comment