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.
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);]
[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]
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; Nov 26th, 2009 at 11:05 am. Reason: Keep It On The Site - Do not manually post "fake" signatures in your posts.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.