Typically you would select the 0 when the user clicks in the field rather than erasing it. That way they can replace it by merely typing a value,but if they leave the field you don't have to reset it. You can find some examples of working with text selection here: http://www.exampledepot.com/egs/javax.swing.text/Selection.html
That site is very useful for finding short code examples for many things and is worth keeping bookmarked :)