Forums Register Login

Change the background color of TextArea

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
For my next trick, I'll need the help of a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 22605 times.
Similar Threads
how to soloving this problem?
saving program settings--need some sample code
Change color of a LookAndFeel
html form controls
Customizing window icons...
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:37:09.