Results 1 to 2 of 2

Thread: Strings...

  1. #1

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228

    Strings...

    I need to find the bounds of a String in order to center it in a rectangle when painted with a instance of Graphics. HOW DO I DO THIS???
    To protect time is to protect everything...

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Code:
    //...
    public void paint(Graphics g)
    {
    	FontMetrics fm = g.getFontMetrics();
    
    	int w = fm.stringWidth("Some String!");
    	int h = fm.getHeight();
    }
    //...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width