0

Hi!

I'm making a hangman in Java, running it with Eclipse. I was wondering if it's possible to clear the screen (the previously printed text) in some way, so my program would have a more natural feel to it, instead of just going from the top of the page to the bottom after every print statement.

PS. I'm aware of the method when i can just print a lot of newlines, but that's not what i'm looking for.

Thank you very much!

stensootla
  • 13,945
  • 9
  • 45
  • 68
  • possible duplicate of [How to clear console in Java - Eclipse SDK](http://stackoverflow.com/questions/10509476/how-to-clear-console-in-java-eclipse-sdk) – Fritz Feb 18 '13 at 17:11
  • I actually read this post before i made mine, but i didn't get an answer from there. – stensootla Feb 18 '13 at 17:19
  • Did you notice the part about Eclipse's bug? – Fritz Feb 18 '13 at 17:21
  • Yes, i noticed it, but i thought that maybe there's another way to clear the screen that wasn't mentioned in this post we are talking about and that someone who may know the solution, answers to this thread instead. – stensootla Feb 18 '13 at 17:23

2 Answers2

0

If you're running this in a command prompt, you may want to use VT100 escape codes to do this. The Jansi library looks like it would provide this functionality. See here:

http://jansi.fusesource.org/documentation/api/org/fusesource/jansi/Ansi.html#eraseScreen()

Please note that I haven't actually used this library, but it looks promising.

Eric Galluzzo
  • 3,191
  • 1
  • 20
  • 20
0

I think this question was answered here so take a look ,it may help you out. Also try to have another look to this thread ,the user @smas gives a very nice answer.

Community
  • 1
  • 1
Andi Domi
  • 731
  • 2
  • 19
  • 48