Re: Real Newbie Question

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 12/21/03

  • Next message: - ions: "TextField error checking"
    Date: Sun, 21 Dec 2003 11:28:55 GMT
    
    

    "Rob" <talon2lm@yahoo.com> wrote in message
    news:c5ydnUUXgYNsg3iiRVn-sQ@comcast.com...
    >
    > Just started Java...This is for my first program.
    >
    > What's the easiest way to center text? Not on an applet, just
    > from command prompt.
    >

    Create a 'String' that is centred within a fixed-width area [e.g. a line
    assumed to be 80 characters in length] by being padded with space [or other
    suitable] characters on either side.

    Some code just to get you started:

        public class MyFirstProgram
        {
           public static void main(String[] args)
           {
               String centredLine =
                   centreText(80, "A CENTRE TITLE", ' ');

               System.out.println(centredLine);
           }

           public static String centreText(int lineLength, String text, char
    padCharacter)
           {
               // Fill with code ...
           }
        }

    I hope this helps.

    Anthony Borla


  • Next message: - ions: "TextField error checking"

    Relevant Pages

    • RE: Pattern Match
      ... Rob, can you explain the details of that replace? ... > I am very new to Perl, but I sense a great adventure ahead after just ... not a list of characters. ... to the ASCII value of the control character grabbed by the regex. ...
      (perl.beginners)
    • Re: all matches of a regex-continued
      ... Rob has suggested me a good solution for macthing consecutive patterns like ... > Your suggestion was quite helpful but I got stuck when I try to modify it for ... which takes a string of characters to ...
      (perl.beginners)
    • Re: format of characters change in the layout of a webpage in the punctuation marks
      ... Rob ... > You can also get to the Internet Explorer newsgroups via this web site: ... > There select Internet Applications then Internet Explorer ... >> the characters instead look like chinese characters. ...
      (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
    • Re: [kde] =?iso-8859-1?q?How_to_set_up_my_kbd_to_be_able_to_use_Frenc?= =?iso-8859-1
      ... non-keyboard characters very well. ... To install right click on the Panel>Add to Panel>Applet>Character ... Selector. ... The problem for me with the panel applet, is that my eyes are not very ...
      (KDE)
    • Re: "Jericho" demo first impressions.
      ... Rob wrote: ... but if you switch between characters and make full use of their ... on-screen button mashing sequence" is a real killer for me though. ...
      (comp.sys.ibm.pc.games.action)