• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Change the background color of TextArea

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic