Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

need some java help..... *fast*

  • 12-04-2001 1:38pm
    #1
    Registered Users, Registered Users 2 Posts: 7,626 ✭✭✭


    how do you skip to the next line in a string?? i'm doing applets.... and the /n or whatever doesn't work.

    help please smile.gif

    - Ciaranj - ciaranj.com

    This post has been brought to you by the letter C, and the number 7.


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    \n should work. What are you trying to do exactly?


  • Registered Users, Registered Users 2 Posts: 2,660 ✭✭✭Baz_


    where are you outputting to ie. are you using the paint method. If you are then you have to specify the coordinates you want the string drawn at. I am assuming you're not however and if not then yes '\n' should work in almost all other cases.


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    (yes i help ppl, because im nice!)

    u should make an array of strings, one for each line, then do a for loop:

    int yCoordinate = 20;
    for(int i = 0; i < stringArray.lenth; i++){
    g.drawString(stringArray, 20, yCoordinate);
    yCoordinate+=15;
    }

    this will draw each line starting at 20,20 and then 20,35 then 20,50 etc...


    - Dead Bank Clerk -
    [clergy]Altar Boy
    "Build a man a fire, and he'll
    be warm for a day. Set a man on
    fire, and he'll be warm for the
    rest of his life."

    [This message has been edited by DeadBankClerk (edited 12-04-2001).]


  • Registered Users, Registered Users 2 Posts: 2,281 ✭✭✭DeadBankClerk


    or to make it even nicer u can use java to get the height of ur font (i dont know the method's name)

    and u could say:

    yCoordinate = yCoordinate + font.getHeight() + 3 //(a few pixles for space)


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    If you want to get the pixel sizes of a font you need to use the FontMetrics class.
    FontMetrics fm = g.getFontMetrics(font);
    
    gets the FontMetrics object of your graphics context, and then you can use fm.getWidth() or fm.getHeight(), or a whole load of other methods that are listed in the API docs.


  • Advertisement
Advertisement