formatted printing of text- color

Discussion in 'Java' started by babo, Nov 29, 2005.

  1. babo

    babo Guest

    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
     
    babo, Nov 29, 2005
    #1
    1. Advertising

  2. babo

    Oliver Wong Guest

    "babo" <> wrote in message
    news:...
    >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
     
    Oliver Wong, Nov 29, 2005
    #2
    1. Advertising

  3. babo

    zero Guest

    "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
     
    zero, Nov 29, 2005
    #3
  4. babo

    babo Guest

    #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
     
    babo, Nov 29, 2005
    #4
  5. babo

    babo Guest

    #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 ...
     
    babo, Nov 29, 2005
    #5
  6. babo

    zero Guest

    "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
     
    zero, Nov 30, 2005
    #6
  7. babo

    Roedy Green Guest

    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.
     
    Roedy Green, Nov 30, 2005
    #7
  8. 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.
     
    Jeffrey Schwab, Nov 30, 2005
    #8
  9. "babo" <> wrote in message
    news:...
    > #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

    :)
     
    Luc The Perverse, Nov 30, 2005
    #9
  10. babo

    Roedy Green Guest

    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.
     
    Roedy Green, Nov 30, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stuart Woodard

    Server-side Printing With Formatted Text

    Stuart Woodard, Aug 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    315
    Stuart Woodard
    Aug 3, 2003
  2. Clint MacDonald

    Borderless formatted Printing from ASP.NET

    Clint MacDonald, May 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    850
  3. Thomas Philips
    Replies:
    7
    Views:
    345
    Josiah Carlson
    May 21, 2004
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    431
    Kamaljeet Saini
    Feb 13, 2009
  5. Replies:
    7
    Views:
    380
    Mick White
    Feb 2, 2005
Loading...

Share This Page