The issue isn't that one or the other does not work but that one of the two forces inolved is much stronger than the other, in effect rendering one negligible. A mouse joint is by default much more powerful than gravity, hence explaining the scenario if you set the mass before creating the joint. If you do not set the mass before creating the joint, the maximum force of the mouse joint will be initialized using the present mass as basis: 0, as though there were no mouse joint.
Try setting maxForce of the mouse joint to 0.01 times the gravity times the inertia of the body, after setMassFromShapes(). This should keep the two forces somewhat balanced, regardless of whether or not you place setMassFromShapes before or after you create the mouse joint.
thank u for reply, but seems it's bad idea
when i change the maxForce it's not effect on anything, as inertia. When i change the gravity, body became unstable and move down only when i help by clicking ( it starts the mouseJoint:setTarget(x_, y_)), bad move up and beside, it's going like for parabola i was trying dif gravities...