Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

new line in applet string

843807Mar 17 2007 — edited Apr 10 2007
I am making an applet that will roll dice and print out the results. The results are printed using a variable string in a paint method, in this case "a". I am having issue making a new line before each set of new rolls and dont know what to do.

Here is the method I am having issues with:
public void roller(int sides, int rolls){
	if(rolls>0){
		a=a+"On a "+sides+" sided die you rolled: ";
		for(int T=0; T<rolls; T++){
			int result = (int)(Math.random()*sides+1);
			a= a + result;
			if(T<rolls-1){a=a+", ";}
			repaint();
		}
	}
}
I have tried \n but that doesnt seem to work.
I have also tried using
newline = System.getProperty("line.separator"); 
but it wont seem to work either.

any and all help is apreciated thanks.

oh and if that was to vague please say >.<
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2007
Added on Mar 17 2007
1 comment
199 views