This site requires JavaScript, please enable it in your browser!
Greenfoot back
_wade
_wade wrote ...

2014/12/23

Indent a String?

_wade _wade

2014/12/23

#
I have this string, but between "Game Over" and "Press Space To Replay" I want an Indentation. So instead of an output of "Game Over Press Space To Replay" I want: Game Over Press Space To Replay String text = "Game Over Press Space To Replay"; GreenfootImage textImage = new GreenfootImage(text, 100, Color.white, new Color(0, 0, 0, 0)); GreenfootImage image = new GreenfootImage(textImage.getWidth()+20, textImage.getHeight()+10); image.drawImage(textImage, (image.getWidth()-textImage.getWidth())/2, (image.getHeight()-textImage.getHeight())/2); setImage(image); Should I just create another string or is there an easy way to indent this the way I would like to? Thank you!
danpost danpost

2014/12/23

#
There are escape sequences you can use to modify the way a string is output in most situations. Near the bottom of this page of the Java tutorials is a table for them.
_wade _wade

2014/12/26

#
danpost wrote...
There are escape sequences you can use to modify the way a string is output in most situations. Near the bottom of this page of the Java tutorials is a table for them.
It works! :)
You need to login to post a reply.