@Override
    public void mouseDragged(MouseEvent e) {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
       if (e.getSource().equals(EditingPane))
               {
                    long hereIAm = System.currentTimeMillis();
                    bg.setStroke(new BasicStroke(thickness.getValue(),BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
                    if (doodles[kind]==null)
                    {
                        bg.setColor(colors[kind]);
                    }
                    else
                    {
                        bg.setPaint(doodles[kind]);
                    }
                    if (hereIAm-timeNoSee<100)
                     {
                         bg.drawLine(x, y, e.getX(), e.getY());
                         //FillLine(x,y,e.getX(),e.getY(),thickness.getValue(),(byte)kind);
                         synchronized (bufferedStrokes)
                                 {
                         bufferedStrokes.add(new BrushStroke(x,y,e.getX(),e.getY(),thickness.getValue(),kind));
                         buffering.setValue(0);
                         max = bufferedStrokes.size();
                         count = 0;
                         buffering.setForeground(Color.red);
                                 }
                         //bg.fillArc(x-2, y-2, 4,4, 0, 360);
                         //bg.fillArc(e.getX()-2, e.getY()-2, 4,4, 0, 360);
                         EditingPane.getGraphics().drawImage(bi, 0, 0, rootPane);
                     }
                     x = e.getX();
                     y = e.getY();
                     timeNoSee = hereIAm;
               }
       if (e.getSource().equals(jScrollPane1))
               {
                    EditingPane.getGraphics().drawImage(bi, 0, 0, rootPane);
               }
    }