Clear screen

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPhreak

    Clear screen

    How would you clearn the screen in a console program???

    Thanks
    NeoPhreak >.<


  • Anthony Borla

    #2
    Re: Clear screen


    "NeoPhreak" <admin@neophrea k.com> wrote in message
    news:vScsb.3128 $IK2.284199@new s20.bellglobal. com...[color=blue]
    > How would you clearn the screen in a console program???
    >[/color]

    Console control is not Java's strong point. Generally there are three
    approaches to this task:

    * Use 'System.out.pri ntln' to write out enough space characters to
    fill the screen [doesn't, however, provide very effective cursor
    control :) !]

    * If the console suports ANSI escape sequences, then the
    following will do the trick:

    final static String ESC = "\033[";
    System.out.prin t(ESC + "2J"); System.out.flus h();

    * Use a JNI routine that makes the relevant OS system
    call to perform this task. You should find these in
    console-based libraries - do a search for JCurses or
    any other Java-based Curses implementation

    I hope this helps.

    Anthony Borla

    P.S.

    Forget about your Java program responding to single keystrokes [i.e. without
    the need to press ENTER]. Again, a suitable JNI routine or package like
    JCurses is required


    Comment

    • DaiIchi

      #3
      Re: Clear screen

      On Tue, 11 Nov 2003 16:52:45 -0500, "NeoPhreak" <admin@neophrea k.com>
      wrote:
      [color=blue]
      >How would you clearn the screen in a console program???
      >
      >Thanks
      >NeoPhreak >.<
      >[/color]

      Depends on the operating system... on Windows 9x and most flavors of
      Unix (in a terminal window) you can use:

      System.out.prin tln(((char) 27)+"[2J"); // ANSI clear screen...

      But NOTHING works in Windows NT. So you can write some JNI code, or
      do something silly like:

      for (int i=0; i<25; ++i) System.out.prin tln();


      Comment

      • Denz

        #4
        Re: Clear screen

        Never did find a way to do that ...
        cheers

        "NeoPhreak" <admin@neophrea k.com> wrote in message
        news:vScsb.3128 $IK2.284199@new s20.bellglobal. com...[color=blue]
        > How would you clearn the screen in a console program???
        >
        > Thanks
        > NeoPhreak >.<
        >
        >[/color]


        Comment

        • Tony Morris

          #5
          Re: Clear screen



          --
          Tony Morris
          (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
          Software Engineer
          IBM Australia - Tivoli Security Software


          "Denz" <RUBBISHdgeller t@RUBBISHhotmai l.com> wrote in message
          news:tBgCb.4951 7$aT.42373@news-server.bigpond. net.au...[color=blue]
          > Never did find a way to do that ...
          > cheers
          >
          > "NeoPhreak" <admin@neophrea k.com> wrote in message
          > news:vScsb.3128 $IK2.284199@new s20.bellglobal. com...[color=green]
          > > How would you clearn the screen in a console program???
          > >
          > > Thanks
          > > NeoPhreak >.<
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...