permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes centralising characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "centralising characters" Watch "centralising characters" New topic
Author

centralising characters

John Coleman
Ranch Hand

Joined: Jul 24, 2001
Posts: 65
I want display individual characters centralised inside a box so that I can create a sort of grid with them equally spaced - this would be like a centered baseline monospaced characterset.

I can't see how with lower case letters once can discover how much to shift them to get them central, although this can be achieved somewhat with caps.

Is there any way to make my own font up perhaps, and bundle that with the application?

TIA
John


John Coleman, MSTA<br />Sun Certified Programmer for the Java� 2 Platform<br />john.coleman@eurobase-international.com<br />Eurobase banking solutions<br /><a href="http://www.eurobase-international.com/banking" target="_blank" rel="nofollow">http://www.eurobase-international.com/banking</a>
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
You can usually get pretty close using methods of the Font class.
Here's one way to do it.
Other options include the TextLayout and GlyphVector classes.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Too cool! I twiddled it to show some lower-case characters too:



Thanks for the clever code.

/Pete
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: centralising characters
 
Similar Threads
Limit JTextField number of characters
Unicode in TextArea
Devnagari characters
Hanlde control characters in Servlet
CycleChars