Well, yes it is. But there's a lot of obscure classes involved. I wrote code like that about five years ago and I haven't looked at it since, so I'll just give a brief outline.
First you have to put your hundred-number
string into an AttributedString along with the details of the Font you plan to use. That includes the size of the Font, so you will want to repeat this with different Font sizes until you find one which works.
Next get the width of the component you want to display the string into.
You should be able to get a Dimension object from the component and then get its width.
Finally you need some code like this:
At least I think that's right, I've extracted that snippet from a more complicated bit of code which is supposed to wrap the text into a block of fixed width. So you will probably have to play around with it. You might also want to search out a tutorial dealing with those classes, because that's most likely where I found out about them.