| | |
JTextArea & Font Color
![]() |
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.
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
FireFox
Hijack This
Ad-Aware
Hijack this tutorial
Microsoft AntiSpyware
CompUchat
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Solved Threads: 0
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]
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]
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Solved Threads: 0
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
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.
Try this complete source code :
<URL SNIPPED>
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);
}
} 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.
![]() |
Similar Threads
- Change <div> text color & font without refreshing page (JavaScript / DHTML / AJAX)
Other Threads in the Java Forum
- Previous Thread: stringlist
- Next Thread: game in which language
| Thread Tools | Search this Thread |
add android api applet application applications array arrays automation bank binary bluetooth chat class clear client code codesnippet collections component converter database development dice digit eclipse equation error event formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jni jpanel julia linux list loop looping main map method methods mobile myregfun mysql netbeans newbie nonstatic openjavafx parameter pearl php print problem program programming project recursion repositories scanner scrollbar server set size sms sort sorting spamblocker sql sqlserver state storm string superclass swing swt text-file thread threads tree windows






