Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > formatted printing of text- color

Reply
Thread Tools

formatted printing of text- color

 
 
babo
Guest
Posts: n/a
 
      11-29-2005
I don't know how to use println with diferent color of text from
default and to print ascii of card signes, like hearts, spike, etc...


like: System.out.println("This text is RED, and this is BLUE")


Thnx

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      11-29-2005

"babo" <> wrote in message
news: oups.com...
>I don't know how to use println with diferent color of text from
> default and to print ascii of card signes, like hearts, spike, etc...
>
>
> like: System.out.println("This text is RED, and this is BLUE")
>
>
> Thnx


Colors are terminal specific (and thus OS specific (and thus probably
you won't find direct support for that within Java)). Try looking up ANSI as
a starting point.

For the card suits and things like that, you can probably find
appropriate symbols in Unicode, which Java fully supports.

- Oliver


 
Reply With Quote
 
 
 
 
zero
Guest
Posts: n/a
 
      11-29-2005
"babo" <> wrote in news:1133303338.159155.299140
@g49g2000cwa.googlegroups.com:

> I don't know how to use println with diferent color of text from
> default and to print ascii of card signes, like hearts, spike, etc...
>
>
> like: System.out.println("This text is RED, and this is BLUE")
>
>
> Thnx
>
>


There currently is no way to change the colour of the output on the console
window.

There are no ascii heart or spike symbols, so that's out too.

You may want to look into using a Swing GUI with a JEditorPane.

--
Beware the False Authority Syndrome
 
Reply With Quote
 
babo
Guest
Posts: n/a
 
      11-29-2005
#include <stdio.h>
#include <conio.h>

int main () {
char i;

for (i=0;i<=102;i++)
{
printf ("\n%2c %4d",i,i);
}
getch ();
}
//this will print You a ascii hearts and spikes in the begining???and
then the letters

 
Reply With Quote
 
babo
Guest
Posts: n/a
 
      11-29-2005
#include <stdio.h>
#include <conio.h>

int main () {
char i;

for (i=0;i<=102;i++)
{
printf ("\n%2c %4d",i,i);
}
getch ();
}
//this will print You a ascii hearts and spikes in the begining???and
then the letters

//ofcourse in c language ...

 
Reply With Quote
 
zero
Guest
Posts: n/a
 
      11-30-2005
"babo" <> wrote in news:1133304747.771614.207220
@g44g2000cwa.googlegroups.com:

> #include <stdio.h>
> #include <conio.h>
>
> int main () {
> char i;
>
> for (i=0;i<=102;i++)
> {
> printf ("\n%2c %4d",i,i);
> }
> getch ();
> }
> //this will print You a ascii hearts and spikes in the begining???and
> then the letters
>
> //ofcourse in c language ...
>


This is because the first 32 ASCII characters are non-printing characters
such as tab, newline, backspace, escape, ... How these are represented
depends greatly on the implementation, the platform, and the platform's
settings. Try running this same C program before and after setting the
KEYB setting on DOS systems (I don't know if it still works on 32 bit
windows systems). You will get very different results.

You can see the complete ASCII table at http://www.asciitable.com/ Compare
the output from your code above to the table, and you will see that the
first 32 characters come out differently, but after that it should be the
same.

The bottom line is, you can't do what you want in ASCII code. Unicode
might help, but you're still not going to get the colours you mentioned in
your first post.

Why do you want this in the console window anyway? If you want something
that looks nice, you really need a GUI.

--
Beware the False Authority Syndrome
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-30-2005
On 29 Nov 2005 14:28:58 -0800, "babo" <> wrote,
quoted or indirectly quoted someone who said :

>I don't know how to use println with diferent color of text from
>default and to print ascii of card signes, like hearts, spike, etc...


Consoles don't support colour. You have to create your own logging
window that supports colour.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Jeffrey Schwab
Guest
Posts: n/a
 
      11-30-2005
Roedy Green wrote:
> On 29 Nov 2005 14:28:58 -0800, "babo" <> wrote,
> quoted or indirectly quoted someone who said :
>
>
>>I don't know how to use println with diferent color of text from
>>default and to print ascii of card signes, like hearts, spike, etc...

>
>
> Consoles don't support colour. You have to create your own logging
> window that supports colour.


Most consoles do support color. The problem is that different consoles
support color in different ways. There are libraries that can shield
applications from the differences between different console interfaces.
A quick Google turns up this library, which I have not used:

http://sourceforge.net/projects/javacurses/

Alternatively, if the output is meant only for logging, it might be
easier to write some kind of rich text, e.g. HTML. If the output is to
be read in real-time, and color is absolutely necessary, Swing might be
the best option.
 
Reply With Quote
 
Luc The Perverse
Guest
Posts: n/a
 
      11-30-2005
"babo" <> wrote in message
news: ups.com...
> #include <stdio.h>
> #include <conio.h>
>
> int main () {
> char i;
>
> for (i=0;i<=102;i++)
> {
> printf ("\n%2c %4d",i,i);
> }
> getch ();
> }
> //this will print You a ascii hearts and spikes in the begining???and
> then the letters


But . . . um . .that's not a java program

--
LTP




 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-30-2005
On Wed, 30 Nov 2005 00:57:29 GMT, Jeffrey Schwab
<> wrote, quoted or indirectly quoted someone who
said :

>Most consoles do support color.


Console as a special meaning in java. It does not just mean a log
display. It is implemented in a platform independent way, which is
why no colour.

It is surprisingly easy to write your own console log class that has
colour, timestamping, persistence etc.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing font color from current font color to black color Kamaljeet Saini Ruby 0 02-13-2009 04:58 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:52 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:50 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57