• Post Reply Bookmark Topic Watch Topic
  • New Topic

Way to clear screen?  RSS feed

 
Ben Cramphorn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to clear the screen and move the cursor back to the top of the screen???

What I want is after I have don't something in my program is to ruturn to the main menu. However at the moment when I return to the main menu it jsut appears at the bottom of the screen with all the previous text above it..

A way to clear the screen would be cool

Thanks...
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Cramphorn:

A way to clear the screen would be cool


Cool, but not platform independent. Also, most applications use a windowed GUI in favor of a console interface. Given these two reasons, it's no surprise that Java has limited console capabilities. Check out this post for your options.
 
Ben Cramphorn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you and apologies for the late reply.
 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben Cramphorn wrote:Thank you and apologies for the late reply.


12 years!?

Now you're a man who's all about tying loose ends!
 
Paul Clapham
Sheriff
Posts: 22509
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome back to the Ranch, Ben!
 
Tim Holloway
Bartender
Posts: 18715
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that isn't a record, I'd like to know what is!

A lot of devices will honor a "Control-L" character code. I believe that hex 0C. Its official ASCII name is "form feed", and on compliant text printers, it initiates a page eject operation. Which is the paper equivalent of clearing the screen and going to the top, so a lot of "glass TTY" monitors adopted CTL-L as a clear-screen convention as well. With the advent of window-based GUI systems, virtual terminals became popular and true to their name, they mimicked the behavior of their corresponding physical terminals.

Older terminal apps usually allowed you to configure to emulate specific popular physical terminals, such as the DEC VT-100 terminal. A quick look at my desktop seems to indicate that these days, the virtual terminals are more generic and abstract.

There are common escape sequences for positioning the text cursor, blanking, color and intensity and so forth. The Unix/Linux curses package was created to translate them to hardware-specific command sequences so that portable "text gui" apps could be written. That was useful back before servers commonly ran with windowing systems. And frankly, I'm not keen on the trend that servers should be required to be running high-resolution graphics/window systems anyway, I do most of my administration from a remote console so having all that overhead on the server is mostly just an annoyance that prevents me from recycling older monitors and video cards.

So, if you're brave, I recommend outputting a CTRL-L and buffer flush. It will work in an awful lot of cases, but not all of them. If full portability is essential, then you need to be working with a graphics manager and issuing graphics API commands.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!