Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Putting a split String in a printout.

Putting a split String in a printout.

Scheduled Pinned Locked Moved Java
graphicshelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chdboy
    wrote on last edited by
    #1

    I have a String which has been splitted like this

    String companyinforstring ="Company name.:Company profile no 1.:Company profile no 2.:Company profile no3.:---------------------------------------------------------------:Company address, :Street number, :Area,Area no2, :City. ";
    for (String retval: companyinforstring.split(":"))
    {
    System.out.println(retval);
    graphics.drawString(retval.toUpperCase(), 250, 200);
    }
    

    The Problem is that String which has been splitted, overlaping each String,How can this be solved?

    L 1 Reply Last reply
    0
    • C chdboy

      I have a String which has been splitted like this

      String companyinforstring ="Company name.:Company profile no 1.:Company profile no 2.:Company profile no3.:---------------------------------------------------------------:Company address, :Street number, :Area,Area no2, :City. ";
      for (String retval: companyinforstring.split(":"))
      {
      System.out.println(retval);
      graphics.drawString(retval.toUpperCase(), 250, 200);
      }
      

      The Problem is that String which has been splitted, overlaping each String,How can this be solved?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      graphics.drawString(retval.toUpperCase(), 250, 200);

      You are drawing every line at the same point.

      Veni, vidi, abiit domum

      C 1 Reply Last reply
      0
      • L Lost User

        graphics.drawString(retval.toUpperCase(), 250, 200);

        You are drawing every line at the same point.

        Veni, vidi, abiit domum

        C Offline
        C Offline
        chdboy
        wrote on last edited by
        #3

        String[] str1 = companyinforstring.split(":");
        for(int i=0;i

        Is there any simple way of doing it?
        Please let me know

        L 1 Reply Last reply
        0
        • C chdboy

          String[] str1 = companyinforstring.split(":");
          for(int i=0;i

          Is there any simple way of doing it?
          Please let me know

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          chdboy wrote:

          Is there any simple way of doing it?

          Of course, use a loop, something like:

          int lineHeight = 10;
          int currentLine = 50;
          for (String strText: companyinforstring.split(":"))
          {
          graphics.drawString(strText.toUpperCase(), 360, currentLine);
          currentLine += lineHeight;
          }

          Veni, vidi, abiit domum

          C 1 Reply Last reply
          0
          • L Lost User

            chdboy wrote:

            Is there any simple way of doing it?

            Of course, use a loop, something like:

            int lineHeight = 10;
            int currentLine = 50;
            for (String strText: companyinforstring.split(":"))
            {
            graphics.drawString(strText.toUpperCase(), 360, currentLine);
            currentLine += lineHeight;
            }

            Veni, vidi, abiit domum

            C Offline
            C Offline
            chdboy
            wrote on last edited by
            #5

            thanks a lot :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups