> I am working on a chat applet, and I would like it to show an image
> next to some text received from the server. I have looked everywhere I
> can think of for a similar piece of code, but I haven't succeeded yet.
AWT applets can show images, but..
> I use a TextArea for inserting the text received but I don't know how
> to insert the image into the TextArea next to the text.
java.awt.TextArea will not display images.
> ..Is there any
> way to do this?
Yes, you could put the image on a
Canvas/Panel/Component beside the
TextArea, and render the image on it.
You could (theoretically) also use javax.swing.JEditorPane
<http://www.physci.org/api.jsp?license=OK&class=javax.swing.JEditorPane>
to display (simple) HTML formatted text,
with the chat text and image interwoven
in the HTML.
Have you used Swing yet?

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Fahd Shariff - 19 May 2004 11:23 GMT
JTextPanes support embedded components:
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html

Signature
Fahd Shariff
http://www.fahdshariff.cjb.net
"Let the code do the talking..."
VisionSet - 19 May 2004 11:34 GMT
> > I am working on a chat applet, and I would like it to show an image
> > next to some text received from the server. I have looked everywhere I
[quoted text clipped - 6 lines]
>
> java.awt.TextArea will not display images.
Well that isn't entirely true. You can override paintComponent and display
whatever you like. But that would be an extremely odd thing to do.
--
Mike W
Miguel Angel - 19 May 2004 23:06 GMT
First of all, let me thank you for your replies, and apologise for
posting this twice.
My problem is that I am going to use the program in schools and it is
a very heterogeneous environment. I don't know what software nor
hardware it will be used from. So to play it safe I think AWT will be
better (correct me if I am wrong).
Anyway I will try the canvas solution and see how I go. If you have
any further comments I will appreciate them.
Miguel
Andrew Thompson - 19 May 2004 23:16 GMT
> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message
...
>> java.awt.TextArea will not display images.
>
> Well that isn't entirely true.
True. I have to consider whether to type the entire
truth or keep it short and to the point. On c.l.j.help
I often give the abbreviated response in the expectatation
that the OP will find out at a later (relevent) stage
that my statement was not entirely correct.
OTOH, ..if you were going to do your own rendering,
is there any point in sub-classing a more complex
Object than Component? ;-)

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology