JTextArea & Font Color

Reply

Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

JTextArea & Font Color

 
0
  #1
Mar 1st, 2005
Is there a way to change the color of the text in a JTextArea? I want to change all the text color to one color (other than black) and I just want to know how to do this. I see a lot of methods involving color but they only effect the text "highlighting" portion.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: JTextArea & Font Color

 
0
  #2
Mar 1st, 2005
textArea.setForeground(Color.blue);

There might be some mistakes in the Foreground part, I can't remember how to spell right now, nor which letters to capitalize.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 780
Reputation: OurNation is an unknown quantity at this point 
Solved Threads: 9
OurNation's Avatar
OurNation OurNation is offline Offline
Master Poster

Re: JTextArea & Font Color

 
0
  #3
Mar 1st, 2005
It looks right to me and capitilaztion looks right.
PETA People for the Eating of Tasty Animals.


FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: JTextArea & Font Color

 
0
  #4
Mar 7th, 2005
i agree...
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 1
Reputation: acomer is an unknown quantity at this point 
Solved Threads: 0
acomer acomer is offline Offline
Newbie Poster

Re: JTextArea & Font Color

 
0
  #5
Nov 27th, 2007
Where in my code do I put the command to change my font color? I have a slate background on my page and my other text is all in black, but the text from my code does not show up on my page.

This is the line from above: [textArea.setForeground(Color.black);]

and this is the code for my form:

[form method=post action="http://www.comerzcustomz.com" name="emailform" onSubmit="return checkFields()"]

[input type=hidden name=to value="chris@comerzcustomz.com"]
[input type=hidden name=subject value="Feedback Form"]

[pre]
Your Name: [input type=text name="name"] (this is the font that I want to change)
Your Email: [input type=text name="email"] (this is the font that I want to change)


Comments? (this is the font that I want to change) [textarea name="comments" wrap="virtual" rows="7" cols="45"][/Textarea]

[input type=submit value="Submit Form!"]


[/pre]
[/form]
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1
Reputation: JavaWizz is an unknown quantity at this point 
Solved Threads: 0
JavaWizz JavaWizz is offline Offline
Newbie Poster

Re: JTextArea & Font Color

 
0
  #6
Mar 4th, 2008
Hi acomer, This is about Java not HTML for html you need to use CSS
This should be your code:

[form method=post action="http://www.comerzcustomz.com" name="emailform" onSubmit="return checkFields()"]

[input type=hidden name=to value="chris@comerzcustomz.com"]
[input type=hidden name=subject value="Feedback Form"]

[pre]
Your Name: [input type=text name="name" style="color:blue; font:bold 12px Veranda;"]
Your Email: [input type=text name="email" style="color:blue; font:bold 12px Veranda;"]


Comments?[textarea name="comments" wrap="virtual" rows="7" cols="45" style="color:blue; font:bold 12px Veranda;"]][/Textarea]

[input type=submit value="Submit Form!"]


[/pre]
[/form]

The stuff in bold can be changed to what you want it to be
Last edited by JavaWizz; Mar 4th, 2008 at 7:22 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 2
Reputation: carnado2008 is an unknown quantity at this point 
Solved Threads: 0
carnado2008's Avatar
carnado2008 carnado2008 is offline Offline
Newbie Poster

Re: JTextArea & Font Color

 
0
  #7
Mar 5th, 2009
Try this complete source code :
import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.Color;
import java.awt.FlowLayout;

public class SetJTextAreaTextColor
{
	public static void main(String[]args)
	{	
		//Create text area using JTextArea 
		JTextArea textArea=new JTextArea();

		//Create JFrame with title ( Set JTextArea text color )
		JFrame frame=new JFrame("Set JTextArea text color");

		//Set color base on RGB
		//You can get RGB value for your color at "Color picker" at above
		//R=255
		//G=0
		//B=0
		Color color=new Color(255,0,0);
		
		//Set JTextArea text color to color that you choose
		textArea.setForeground(color);
		
		//Add JTextArea into JFrame
		frame.add(textArea);
		
		//Set default close operation for JFrame
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		//Set JFrame size
		frame.setSize(500,300);
		
		//Make JFrame visible
		frame.setVisible(true);
	}
}
<URL SNIPPED>
Last edited by peter_budo; 5 Days Ago at 11:05 am. Reason: Keep It On The Site - Do not manually post "fake" signatures in your posts.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC