For Programmers: Free Programming Magazines  


Home > Archive > Java Help > May 2004 > TextArea and images









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author TextArea and images
Miguel Angel

2004-05-19, 2:31 am

Hi,

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.

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. Is there any
way to do this?
I also want some of the text and the image to be hyperlinked to other
web pages for loading upon cliking. I think I have found how to do
this, although I haven't tried it yet.

Any help specially with the first question will be appreciated.

Thank you
Miguel
Andrew Thompson

2004-05-19, 2:31 am

On 18 May 2004 22:24:37 -0700, Miguel Angel wrote:

> 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?licen...ing.JEditorPane>
to display (simple) HTML formatted text,
with the chat text and image interwoven
in the HTML.

Have you used Swing yet?

--
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

2004-05-19, 7:32 am

JTextPanes support embedded components:
http://java.sun.com/docs/books/tuto...editorpane.html

--
Fahd Shariff
http://www.fahdshariff.cjb.net
"Let the code do the talking..."
VisionSet

2004-05-19, 7:32 am


"Andrew Thompson" <SeeMySites@www.invalid> wrote in message
news:6eo583z6jgfy$.1e149by0za4n0.dlg@40tude.net...
> On 18 May 2004 22:24:37 -0700, Miguel Angel wrote:
>
>
> AWT applets can show images, but..
>
>
> 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

2004-05-19, 7:31 pm

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

2004-05-19, 7:31 pm

On Wed, 19 May 2004 11:34:41 +0100, VisionSet wrote:

> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message

....
>
> 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? ;-)

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







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com