Hi,
I'm unable to change the font colors by using java. Can u please help me that how can i change the font colors in java.
If you possible please share that respective Font Code.
Thansk & Regards,
Jayavardhan Tummidi.
Hi,
I'm unable to change the font colors by using java. Can u please help me that how can i change the font colors in java.
If you possible please share that respective Font Code.
Thansk & Regards,
Jayavardhan Tummidi.
The fonts of what? If you are referring to Swing then I believe that the classes have set methods for that. Look at their APIs
Do Font's have colors? Or are you talking about what is drawn?
Hi,
Exactly you catch my point. In html or javascript we can easily apply font colors by using <font> tag. But, i asking that how can we apply font colors in java to the specific text like "Contract". I need this text Contract appear as a blue.
If you aware of it, then please help along with code.
Thanks & Regards,
Jayavardhan. T
The Idea is good and i need some more infirmation regarding your question
Ok now i came to know u need to apply colour to your text is it right?
Yes, U right.
Hi,Exactly you catch my point. In html or javascript we can easily apply font colors by using <font> tag. But, i asking that how can we apply font colors in java to the specific text like "Contract". I need this text Contract appear as a blue.
If you aware of it, then please help along with code.
Thanks & Regards,Jayavardhan. T
Like I asked: "Do you want to change the color of text in a Swing application?"
If yes, then I told you to look at the API of the components you are using to display your text.
You seem to know how to do it with html. But you failed to provide any useful information of what you want to do. Your question is very vague. And this thread has been getting too long with no useful information.
Can you post code showing where you want the color to be changed?
" I had already describe what my requirement was. Why you always go to swing application? I'm not using any swing application. Is font colors only applicable to swing application or what? I'm asking simple one that how can we change the font colors in simple java application program. I already give an example to compate with html. U are failed to understand the threads properly. Read the thread again and give the answer properly if u can.
" I had already describe what my requirement was. Why you always go to swing application? I'm not using any swing application. Is font colors only applicable to swing application or what? I'm asking simple one that how can we change the font colors in simple java application program. I already give an example to compate with html. U are failed to understand the threads properly. Read the thread again and give the answer properly if u can.
In what kind of java application you are referring to?
PdfPCell cell = new PdfPCell();
Phrase phrase1 = null;
phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, new Color(80,80,80))));
cell.setPhrase(phrase1);
cell.setBackgroundColor(Color.white);
if(IsColor.equals("Y"))
cell.setBackgroundColor(new Color(247,243,247));
table.addCell(cell);
In the above code, new Color(80,80,80) is reflected as white color and setBackgroundColor(new Color(247,243,247) is reflected as pink color. I'm asking that, if i add a blue color instead of white color, what i'm going to write instead of new Color(80,80,80) one.
PdfPCell cell = new PdfPCell(); Phrase phrase1 = null; phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, new Color(80,80,80)))); cell.setPhrase(phrase1); cell.setBackgroundColor(Color.white); if(IsColor.equals("Y")) cell.setBackgroundColor(new Color(247,243,247)); table.addCell(cell);
In the above code, new Color(80,80,80) is reflected as white color and setBackgroundColor(new Color(247,243,247) is reflected as pink color. I'm asking that, if i add a blue color instead of white color, what i'm going to write instead of new Color(80,80,80) one.
I would assume: Color.BLUE
In the code you wrote you do this:
cell.setBackgroundColor([B]Color.white[/B]);
So why didn't you try different colors? Maybe if you would have looked at the API:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Color.html
You would have seen all the different colors you can use. Also you could have found out what the constructor does: new Color(80,80,80)
For Blue you can also try this:
(r,g,b) = (0,0,255)
And yes your question was very vague, because as you pointed out there are many different java applications. And that code should have been in your first post.
I hope..
He did not mean about the back ground colour he is interested in changing his text colour
So refer the below code and suggest a solution if u have ....
Am i right...?
phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]new Color(80,80,80))));[/B]
I hope..
He did not mean about the back ground colour he is interested in changing his text colourSo refer the below code and suggest a solution if u have ....
Am i right...?
phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]new Color(80,80,80))));[/B]
I never said that he should replace the Color.white with Color.BLUE. I said that since he has in his code this: "Color.white" it should be easy to figure out that this: "Color.BLUE" is also applicable.
And that he can place that code "Color.BLUE" wherever he wants. I didn't look whether it was background or foreground color. It is irrelevant.
I wanted to point out how he can use different colors in any case whether you want to change the background or the foreground.
In the same way he did this:
cell.setBackgroundColor(Color.white);
He can do this:
phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]Color.BLUE[/B])));
I never said that he should replace the Color.white with Color.BLUE. I said that since he has in his code this: "Color.white" it should be easy to figure out that this: "Color.BLUE" is also applicable.
And that he can place that code "Color.BLUE" wherever he wants. I didn't look whether it was background or foreground color. It is irrelevant.
I wanted to point out how he can use different colors in any case whether you want to change the background or the foreground.In the same way he did this:
cell.setBackgroundColor(Color.white);
He can do this:
phrase1=new Phrase(18,new Chunk(DisplayString,FontFactory.getFont(FontFactory.HELVETICA, 10,Font.NORMAL, [B]Color.BLUE[/B])));
Edit: For the above codes I assume that we were talking about the Color in this package: java.awt.Color
Yes Right. We are discussed about java.awt.color. Anyway thanks for your replay. I check it out with the same in my application.
how can we apply font colors
Font's don't have colors.
Things that are drawn have colors. Before drawing something, set the color you want and draw it. Then set the color for the next thing and draw it, etc etc
Read the API doc for the Graphics class draw... method and the set... methods
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.