public synchronized void paint(Graphics g) {
    if (mLastFrame == null) {
      return;
    }

    int framePosX = 0;
    int framePosY = 0;

    VideoFrameRef depthFrame = mLastFrame.getDepthFrame();
    if (depthFrame != null) {
      int width = depthFrame.getWidth();
      int height = depthFrame.getHeight();

      // make sure we have enough room
      if (mBufferedImage == null
          || mBufferedImage.getWidth() != width
          || mBufferedImage.getHeight() != height) {
        mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      }

      mBufferedImage.setRGB(0, 0, width, height, mDepthPixels, 0, width);

      framePosX = (getWidth() - width) / 2;
      framePosY = (getHeight() - height) / 2;

      g.drawImage(mBufferedImage, framePosX, framePosY, null);
    }

    for (UserData user : mLastFrame.getUsers()) {
      if (user.getSkeleton().getState() == SkeletonState.TRACKED) {
        drawSkeleton(g, framePosX, framePosY, user);

        // spatial joint's coordinates
        //				giveMeSpatialCoordinateJoints(user);

        try {
          createSkeletonInstances(user);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }

      if (user.getSkeleton().getState() == SkeletonState.TRACKED && startedTest) {
        try {
          createSkeletonInstances(user);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        // System.out.println("send");
      }
    }
  }
  private void drawLimb(Graphics g, int x, int y, UserData user, JointType from, JointType to) {
    com.primesense.nite.SkeletonJoint fromJoint = user.getSkeleton().getJoint(from);
    com.primesense.nite.SkeletonJoint toJoint = user.getSkeleton().getJoint(to);

    if (fromJoint.getPositionConfidence() == 0.0 || toJoint.getPositionConfidence() == 0.0) {
      return;
    }

    com.primesense.nite.Point2D<Float> fromPos =
        mTracker.convertJointCoordinatesToDepth(fromJoint.getPosition());
    com.primesense.nite.Point2D<Float> toPos =
        mTracker.convertJointCoordinatesToDepth(toJoint.getPosition());

    // draw it in another color than the use color
    g.setColor(new Color(mColors[(user.getId() + 1) % mColors.length]));
    g.drawLine(
        x + fromPos.getX().intValue(),
        y + fromPos.getY().intValue(),
        x + toPos.getX().intValue(),
        y + toPos.getY().intValue());
  }