Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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. 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

Report this thread to moderator Post Follow-up to this message
Old Post
Eustace
01-31-08 12:03 AM


Re: Multicolored output
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

Report this thread to moderator Post Follow-up to this message
Old Post
CHAFIK Wassime
03-22-08 11:59 PM


Re: Multicolored output
CHAFIK 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Mishagam
03-23-08 11:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:06 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.