File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change the background color of TextArea

 
netharam ram
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
netharam ram
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic