• Post Reply Bookmark Topic Watch Topic
  • New Topic

Console Menu  RSS feed

 
David Serio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am trying to create a console application. I can present the user with a menu, read the choice, do "something" and return to the menu. However, I would rather clear the screen when showing the menu again. Something like "cls". I am using the command line in Windows XP (Start --> Run --> cmd). Currently the output all runs together, unless I put a bunch of println statements in the code, which doesn't look to nice.

I tried putting this line before outputting the menu, but Java didn't like it when I ran the app:

java.lang.Runtime.getRuntime().exec("cls");

With this line Java didn't complain, but didn't clear the screen either...

java.lang.Runtime.getRuntime().exec("cmd /c cls");


Any pointers?

Thanks,
David
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check out our FAQ
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And never go anywhere near Runtime.getRuntime().exec(); until you have read Michael Daconta when Runtime.exec() won't.
 
David Serio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for the info. I may just use a JTextArea and use that as my "console".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!