wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Setting Defferent Color Of Alphabet In A String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting Defferent Color Of Alphabet In A String" Watch "Setting Defferent Color Of Alphabet In A String" New topic
Author

Setting Defferent Color Of Alphabet In A String

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi Guys,

I am doing on a program to let user enter a Alphabet then the program will search the sentance in put by the user and highlight the Alphabet and display the Alphabet in a different color from the string.

this is the problem i know how to extract the Alphabet from the string but i dun know how to print the string out with individual Alphabet in a different color.

I am open to all suggestion and advice thanks in advance!!!


if (!WorkHard){
System.out.println("Fail!!!");
}
madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
is this a command line application program that we are talking about..?
or is it a GUI ? if its a GUI then ever heard of AWT.

im not sure if the command line program can allow individual characters to change color, but there must be some way i guess so, mean while let me check if i can change colors at when ouputt is on command line prompt


Money for nothing and Java for Free
SCJP, SCWCD
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
hi

Thx for yr help I am doing a GUI program

regards
kkh
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You could use a JEditorPane or even a JLabel:
The JEditorPane has the advantage that it is editable.
[ February 02, 2006: Message edited by: Jeff Albertson ]

There is no emoticon for what I am feeling!
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi

thx i see yr way but it dun't seem to fit in to what i am doing sorry about that may be i never explain my self clearly. I am leting the user to select the color by using the 3 scrollbar which is Red, Green, Blue so how do u go about doing that???

regards
KKH
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Where is the problem? Is it with creating a color from your user's input? Recall that in HTML you can specify color as a number, for example yellow is:

color = "#FFFF00"
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
hi

thx i have a problem. the ptoblem is that i will be checking for vowels agains the string which the user input. then the user will select the RGB color using 3 scroll bar and then click submit then at the bottom the program will print out the string again but this time with the vowels lettes in the color the user select. hope this explaination is a better one thx sry to trouble u so much thx in advance

regards
KKH
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
I think you have described your task fairly, well. I've shown you how Java can use basic HTML markup to add colors to text. I suggest you start coding and post specific questions when you get stuck.
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi

Thx Jeff your method works and i learn something new haha and i did't know that u can display html code in a JLabel Wow once angain thank you.

regards
KKH
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Defferent Color Of Alphabet In A String
 
Similar Threads
Algorithm: Brightness Difference
creating a method to get rid of a repeated code ?
Algorithm: Brightness Difference
Need help extending a program.
Hangman BufferReader ??