AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Basic Question

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
Da Preetham
Guest





PostPosted: Wed May 16, 2007 7:11 am    Post subject: Basic Question Reply with quote



Hi guys, Im Preetham..
Im new to Java and I still learning how to make console programs...
I wanted to know the keyword for clearing the screen in java in a
console program...
Thanks in Advance.
Back to top
Andrew Thompson
Guest





PostPosted: Wed May 16, 2007 7:12 am    Post subject: Re: Basic Question Reply with quote



Da Preetham wrote:
...
Quote:
Im new to Java and I still learning how to make console programs...

That is a good way to learn, but..

Quote:
I wanted to know the keyword for clearing the screen in java in a
console program...

..note that Java is not well suited to doing 'advanced'
things with consoles. It is probably better to
concentrate on learning the core Java classes,
and anytime you feel it is appropriate to clear
the console, do a loop of System.out.println("");
to print a number of blank lines.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200705/1
Back to top
Robert Mark Bram
Guest





PostPosted: Wed May 16, 2007 7:12 am    Post subject: Re: Basic Question Reply with quote



Hi Preetham,

Quote:
I wanted to know the keyword for clearing the screen in java in a
console program...

There is no keyword or command for doing this, because Java doesn't
actually write to a console as such - it writes to an 'output stream',
with no understanding of whether that output stream is being displayed
on a console.. never mind what sort of console (dos, xterm etc).

Instead, what you could do is write enough empty lines to clear your
console:

for (int index = 0; index < 80; index++) {
System.out.println("");
}

The biggest problem with this is how many times should you do it? If
you say "80", you should somehow make sure that all the other people
who are going to run your app have consoles that display 80 lines or
less.

Hope this helps.

Rob
Smile
Back to top
Da Preetham
Guest





PostPosted: Thu May 17, 2007 7:12 am    Post subject: Re: Basic Question Reply with quote

Thanks for the info..
Ill try System.out.println("\u001B[2J");



On May 17, 2:55 am, Joshua Cranmer <Pidgeo...@epenguin.zzn.com> wrote:
Quote:
Da Preetham wrote:
Hi guys, Im Preetham..
Im new to Java and I still learning how to make console programs...
I wanted to know the keyword for clearing the screen in java in a
console program...
Thanks in Advance.

Try using:

System.out.println("\u001B[2J");

That should work in all ANSI-compliant consoles.
Back to top
Da Preetham
Guest





PostPosted: Thu May 17, 2007 7:12 am    Post subject: Re: Basic Question Reply with quote

Thanks Rob.
I have one more question. Which is better c++ or java on the basis of
game programming
Thanks in advanace,
Preetham.


On May 16, 11:44 am, Robert Mark Bram <robertmarkb...@gmail.com>
wrote:
Quote:
Hi Preetham,

I wanted to know the keyword for clearing the screen in java in a
console program...

There is no keyword or command for doing this, because Java doesn't
actually write to a console as such - it writes to an 'output stream',
with no understanding of whether that output stream is being displayed
on a console.. never mind what sort of console (dos, xterm etc).

Instead, what you could do is write enough empty lines to clear your
console:

for (int index = 0; index < 80; index++) {
System.out.println("");

}

The biggest problem with this is how many times should you do it? If
you say "80", you should somehow make sure that all the other people
who are going to run your app have consoles that display 80 lines or
less.

Hope this helps.

Rob
Smile
Back to top
Da Preetham
Guest





PostPosted: Thu May 17, 2007 7:12 am    Post subject: Re: Basic Question Reply with quote

Thanks a lot
On May 16, 11:41 am, "Andrew Thompson" <u32984@uwe> wrote:
Quote:
Da Preetham wrote:

..

Im new to Java and I still learning how to make console programs...

That is a good way to learn, but..

I wanted to know the keyword for clearing the screen in java in a
console program...

.note that Java is not well suited to doing 'advanced'
things with consoles. It is probably better to
concentrate on learning the core Java classes,
and anytime you feel it is appropriate to clear
the console, do a loop of System.out.println("");
to print a number of blank lines.

--
Andrew Thompsonhttp://www.athompson.info/andrew/

Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200705/1
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.