Results 1 to 3 of 3
  1. #1
    dch414 is offline Member
    Join Date
    Sep 2008
    Rep Power

    Default Centering text of output

    Did a search and came up empty. Also hunted on google but nothing of consequence. Does anyone have the answer on how to center the output (text)? The output is just the name of some states and such, nothing complicated. I would post my code but it is lengthy and I don't think it would help. Thanks in advance!

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Rep Power


    not sure what you mean by centering text of output. is this output to the console or to a file? if you want to center output, it will have to be dependent on the width of whatever it is output to. for one, i know not all files or consoles have a limit on line length. if you really wanna look further into it, you just have to indent each line with some kind of ratio dependent on a max line length and the length of the line to be output. where you get this length is up to you.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    Find the center of the output area.
    Find the center of the text to be output.
    Align one center with the other center.
    Take a piece of paper, draw the two items and generate the formula for the distance from the left edge of the output area to the left edge of the text.

Similar Threads

  1. find and replace text from a text file
    By gezzel in forum New To Java
    Replies: 2
    Last Post: 09-19-2008, 05:04 PM
  2. Replies: 0
    Last Post: 05-26-2008, 05:26 PM
  3. Why the output is always zero
    By mehrotra.chitij in forum New To Java
    Replies: 12
    Last Post: 04-25-2008, 05:05 AM
  4. Text Output for a library
    By dream_noir in forum Advanced Java
    Replies: 0
    Last Post: 04-14-2008, 06:31 AM
  5. Simply output the result to a text file.
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 06:48 AM

Posting Permissions

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