Results 1 to 6 of 6

Thread: Clearing concile window

  1. #1

    Thread Starter
    Member
    Join Date
    May 2001
    Location
    Baltimore
    Posts
    61

    Clearing concile window

    I have a question when I send something to the concile window to be printed out like forexample if i say System.out.println("Hello") when I run this once Hello appears if I run it again Hello appears with the previous Hello so it looks like this

    Hello

    Hello

    Is there a way I can clear the concile output window so no matter how many times I run this without killing the program Hello will show once is there some kind of code to clear the concile window before printing Hello to the screen?
    Striver2000

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    I think you mean console. You could go to the dos properties and get the inital line size of the screen then just loop that number of times calling System.out.println(); to push the screen output off the screen.
    Code:
    public class D{
     public static void main(String[] args){
      System.out.println("X");
      for(int screenlines = 0; screenlines <= 10; screenlines++){
      System.out.println();
      }
     }
    }

  3. #3
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111
    I guess when you said the consile window you mean't the command line. If so, It is possible that you can control the attributes like color and stuff, and I'm pretty sure you can clear the console by setting some of the attributes using java code.

    I think you can do it by ANSI escape sequences but I believe you have to modify some of you system files to support it.
    I don't really know how to do this, so no code is available from me.

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    My dos properties says intial lines 25 so when i run the following code
    the X ends up one line almost off screen. So i guess to get it off screen entirely i would need to change screenlines <= 21 to screenlines <= 22 or a higher value .
    Code:
    public class D{
     public static void main(String[] args){
      System.out.println("X");
      for(int screenlines = 0; screenlines <= 21; screenlines++){
      System.out.println();
      }
     }
    }

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Striver2000. I had the same problem a while ago.

    http://www.vbforums.com/showthread.p...hlight=notepad

    You can get a hook to dos but i never figured out a way to execute the cls command via java to clear the screen.

  6. #6
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Clearing concile window

    Check this site out. It shows you how to control attributes of the command line, I think!

    http://www.rgagnon.com/javadetails/java-0047.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width