Re: Multicolored output



CHAFIK Wassime wrote:
Eustace wrote:
I am translating an old QBasic program, that is doing a kind of scan producing an array of digits and printing them on the screen forming a rectangle. In this program I have assigned different colors to different numbers so that it looks like a map, with different colored areas. The result looks something like the first square bellow

6 6 5 4 4 5 5 6 6 7 b b c c c c c b b b
5 5 4 4 3 3 4 5 5 6 c c c c c c c c c b
4 3 3 2 2 2 3 4 4 5 c c c c c c c c c c
2 2 2 1 1 1 2 3 3 4 c c c y y y c c c c
2 1 1 0 0 0 1 2 2 2 c y y y y y y c c c
3 2 1 0 0 0 0 1 1 2 c c y y y y y y y c
3 2 2 1 1 0 1 1 2 3 c c c y y y y y c c
3 3 2 2 1 1 2 2 3 3 c c c c y y c c c c
4 3 3 3 3 2 2 3 3 4 c c c c c c c c c c
4 4 4 4 4 4 4 3 4 4 c c c c c c c c c c
5 5 5 5 5 5 5 5 5 5 c c c c c c c c c c
5 5 5 6 6 6 6 6 6 6 c c c b b b b b b b

With 0-1 digits assigned color yellow, 2-5 color cyan, 5-9 colored blue, the effect is like in the second square, where you can "see" a yellow "island" in the center, within a "shallow sea" of cyan, and "deep sea" of blue.

I understand that in Java I can't use different colored text within a
text area. What's the simplest other option?

Eustace

Hi
i do think that a JTextPane may be what you are looking for

You can use HTML in Java in many places where you can use text. You have to use something like this text:
<html><body>
6 6 <font color=red>5</font> 4 4 <font color=red>5</font> ..... <br>
5 5 4
.....
</body></html>
and select constant width font like ariel.
.



Relevant Pages

  • Re: Beginner Problem - system.out.print
    ... that was only my second java class (so this is going to be SO ... Digits application ... public static void main{ ... If you look through the Java documentation, ...
    (comp.lang.java.programmer)
  • Re: Anime genre: The disaffected/disenchanted office worker.
    ... Dunno how that follows - up till 2001, I was at double digits an hour, ... of Java, 4 years of PHP, etc" that is in demand, I got side-tracked ...
    (rec.arts.anime.misc)
  • Re: I need help!!
    ... length binary file from a COBOL program that was written a long, ... Each byte has two BCD digits in it, ... Oh, and when I mentioned Java, I didn't mean I was doing it "with" ... java, I'm using Record Editor, it's a free and open source alternative ...
    (comp.lang.cobol)
  • Re: converting char to an integer
    ... I think the problems with that method include that other locales will have different characters that represent digits and it will fail for those locales. ... If you are curious about what these characters might be, you can run the following program to find all the characters that Java considers digits and look them up at http://www.unicode.org: ...
    (comp.lang.java.programmer)
  • Multicolored output
    ... I am translating an old QBasic program, that is doing a kind of scan producing an array of digits and printing them on the screen forming a rectangle. ... With 0-1 digits assigned color yellow, 2-5 color cyan, 5-9 colored blue, the effect is like in the second square, where you can "see" a yellow ...
    (comp.lang.java)