Putting a split String in a printout.
-
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?
-
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?
-
graphics.drawString(retval.toUpperCase(), 250, 200);
You are drawing every line at the same point.
Veni, vidi, abiit domum
-
String[] str1 = companyinforstring.split(":");
for(int i=0;iIs there any simple way of doing it?
Please let me knowchdboy 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
-
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