This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Colors in a console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Colors in a console" Watch "Colors in a console" New topic
Author

Colors in a console

Joshua Austin
Greenhorn

Joined: Sep 09, 2002
Posts: 16
I am trying to make a BBS door game, and I need to make the text display localy as well as through the existing bbs connection.
My question applys to displaying text locally (in a console, not in a gui). How do I change the color of the text that is displayed? Also, how do I change the location on the screen that the text is displayed to?
I have done some searching(google.com), and so far the only examples I can find are in a gui app.


/======\/-Computrius-\/=======\<br />"Windows 95 is a 32-bit extension to a 16-bit shell for an 8-bit OS made for a 4-bit processor by a 2-bit company that cant stand 1-bit of competition." -- Unknown
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
This can be done in DOS/Windows using ANSI.SYS. I'm sure you'll find plenty to wade through in google about the escape sequences to specify colors, etc. Since config.sys is not so widely used today, it may not be so obvious how to install it. But I did spot this: http://www.nthelp.com/40/ansiNT.htm
Joshua Austin
Greenhorn

Joined: Sep 09, 2002
Posts: 16
so there is no real way to have it automaticly do color without the end user having to do all this stuff to load ansi.sys?
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
There only thing I recall for DOS windows. The APIs I recall for supporting color in DOS windows required ANSI.SYS, I think. (Installing it on DOS or Win95 systems was routine. But I don't know about anything more recent.) Of course, if your console is some terminal emulator instead of a DOS window, it probably supports color escape directly. See the program documentation. You can buy terminal emulators. I suspect there are some good free ones as well.
Joshua Austin
Greenhorn

Joined: Sep 09, 2002
Posts: 16
I am just printing to whatever the standard console is (using System.out.print) . Weather the console supports ANSI codes depends on what the end user is using to run the program. Its kind of hard to make an installer that does ansi.sys, considering the door game (written in java) will be run under linux, and other OSs' as well, which probably dont use ansi.sys, and may or may not allow ANSI codes.
[ September 09, 2002: Message edited by: Joshua Austin ]
[ September 09, 2002: Message edited by: Joshua Austin ]
John Dale
Ranch Hand

Joined: Feb 22, 2001
Posts: 399
As I recall, the ANSI codes supported by ANSI.SYS are supported by the terminal emulators often used for accessing Unix systems. Perhaps some Unix/Linux user can tell you whether their consoles are typically set up this way.
But, as you observe, it is a pain now, at least on the windows side. It was even a pain back when it was routine, and worse now that it isn't commonly used, at least in the Windows world.
However, among the last widespread consumer (as opposed to business) users of this stuff may be (or have been) the BBS community, so you may find your BBS users are already set up for this. Perhaps you should try to find a older BBS techie. Maybe there are BBS's about BBS technology. :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Colors in a console
 
Similar Threads
Creating A 'Create Your Own Adventure' Game In Java
How to ceate a console window...
how to use a frame in place of console to compile and run any java program????
A question about GUI display~~
changing displayed text in addressbar,locationbar