Drawing dynamically multiple lines in java applet -


when try draw single line in shape , don't know problem. want draw multiple lines store points of old lines in array list repainted each time draw new line.

enter image description here

public class lines11 extends java.applet.applet         implements mouselistener, mousemotionlistener {     private final int maxlines = 10;     private arraylist<point> starts;     private arraylist<point> ends;     private point anchor;     private point currentpoint;     private int currlines;     public void init() {         starts = new arraylist<point>();         ends = new arraylist<point>();         currlines = 0;         this.addmouselistener(this);         this.addmousemotionlistener(this);     }     public void mousepressed(mouseevent e)     {         anchor = new point(e.getx(),e.gety());         repaint();     }       public void mousedragged(mouseevent e)     {         currentpoint = new point(e.getx(),e.gety());         addline(e.getx(),e.gety());         repaint();     }     public void mousemoved(mouseevent e) { }      public void mousereleased(mouseevent e)     {      }     public void mouseclicked(mouseevent e) { }     public void mouseentered(mouseevent e) { }     public void mouseexited(mouseevent e) { }     public void paint(graphics g) {     (int = 0 ; < starts.size()&& i<ends.size() ; i++)         g.drawline(starts.get(i).x,starts.get(i).y,         ends.get(i).x,ends.get(i).y);      }     void addline(int x, int y) {         starts.add(currlines,anchor);         ends.add(currlines,currentpoint);         currlines++;         currentpoint = null;        repaint();     } } 


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -