Code Comments
Programming Forum and web based access to our favorite programming groups.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 -- It ain't THAT, babe! - A radical reinterpretation http://www.geocities.com/itaintme_babe/itaintme.html
Post Follow-up to this messageEustace 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
Post Follow-up to this messageCHAFIK Wassime wrote: > Eustace wrote: > 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.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.