 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Da Preetham Guest
|
Posted: Wed May 16, 2007 7:11 am Post subject: Basic Question |
|
|
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
|
Posted: Wed May 16, 2007 7:12 am Post subject: Re: Basic Question |
|
|
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
|
Posted: Wed May 16, 2007 7:12 am Post subject: Re: Basic Question |
|
|
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
 |
|
| Back to top |
|
 |
Da Preetham Guest
|
Posted: Thu May 17, 2007 7:12 am Post subject: Re: Basic Question |
|
|
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
|
Posted: Thu May 17, 2007 7:12 am Post subject: Re: Basic Question |
|
|
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
 |
|
|
| Back to top |
|
 |
Da Preetham Guest
|
Posted: Thu May 17, 2007 7:12 am Post subject: Re: Basic Question |
|
|
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 |
|
 |
|
|
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
|
|