aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Change the background color of TextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Change the background color of TextArea" Watch "Change the background color of TextArea" New topic
Author

Change the background color of TextArea

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Is it possible to change the background color of a Textarea / JTextarea,instead of white, it should be different.I'am creating a chat aplication.The Frame conatins a non-Editable text area which holds all messages.I wish to develop that window like an application window that comes for most utilities, well designed.Initially I want to know to add color to the background,then images as titles,etc.
Gurpreet Sachdeva
Ranch Hand

Joined: Feb 20, 2001
Posts: 90
Hello Ram,
Please try this:
<pre>
import java.awt.*;
class MyFrame extends Frame
{
MyFrame()
{
TextArea t=new TextArea(20,20);
t.setBackground(Color.yellow);
add(t);
setLayout(new FlowLayout());
setSize(300,300);
setVisible(true);
}
public static void main(String arg[])
{
new MyFrame();
}
}
</pre>
Regards
Gurpreet Sachdeva


Regards<BR>Gurpreet Sachdeva<P>For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: <A HREF="http://www.go4java.lookscool.com" TARGET=_blank rel="nofollow">http://www.go4java.lookscool.com</A>
netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hi, Thank u for u'r code it's working fine.in the same way is there anyway too display the foreground color i.e the text color in different colors.For eg. lets take a chat application, the message sent should be in one color(eg.yellow) & the reply should be in a different color(eg.red).
waiting for u'r reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change the background color of TextArea