free hand lines in Swing - get rid of bug "index out of bound Exception" -
I have to draw a line through a mouse in JFRAM. Here's my method paints Kmpenennt:
public waste Comonent paint (Graphics g) {Graphics2D g2d = (Graphics2D) g; If (pointCollection.get (0)! = Null & amp; amp; amp ;; & amp ;; PointCollection.get (pointCollection.size ())! = NULL) {g2d.setPaint (Color.BLUE); G2d.setStroke (new basicstok (1.5f)); G2d.draw (line2d); }} which is based on my implementation of methods which I have interface icons Monishn and Mauslestonr I
public void Mausdrag (Mausivent Ajhbet) {PointCollection = New Arreelist & lt; Point & gt; (50); PointCollection.add (arg0.getPoint ()); For (int index = 0; index end lie; point coordinates. Size (index; ++) {line2d = new line 2d. Double (Point Collection. Gate (Index), Point Collection.Gate (Index + 1)); // repaint (); }} The idea coach points than draw lines between them, so I get a curved line is not straight. Can you help me make a logical mistake, which I do?
Thank you!
You are going to end at the collection.
public void Mausdrag ged (Mausavent Ajhbak) {for (Int index = 0; index & lt; (pointCollection.size () - 1); index ++) {line2d = new line 2D . Double (Point Collection. Gate (Index), Point Collection. Gate (Index + 1)); // repaint (); } }
Comments
Post a Comment