• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I Center Align text using drawString?

 
Matt Wilcko
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the line:
g2D.drawString("test sentence",350,200);
Any way to get the text center aligned?
Thanks!
 
kyle amburn
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code segment will center a String by passing the startin x,y and the available width.

Kyle
 
dhaya ananth
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

please help me the same above needs to align right...

thanks in advance
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's very similar, so why don't you give it a try and post your best efforts, in the form of an SSCCE <= link

If you're still not getting the desired results, we can then guide you to a successful conclusion.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!