Click to See Complete Forum and Search --> : Java string


bigmac
April 19th, 2001, 12:10 PM
Hi
Is it possible to keep the same distance between the first and last sign in a string even thought the size of the letters vary?
For instance:
g.drawString("string");
g.drawString("!!!!!!");
The width in pixels in my applet vary even though borth strings have the same amount of characters.

Does anyone understand what I'm trying to say? :)

Splatt
April 19th, 2001, 01:27 PM
You need to set the font used in your applet to one that has equal spacing for all characters. Try:


<<OBJECT WHERE TEXT IS BEING DISPLAYED>>.setFont(new Font("monospaced", Font.PLAIN, 12));




"There's nothing more dangerous than a resourceful idiot." ---Dilbert