Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

TextArea and images

Thread view: 
Miguel Angel - 19 May 2004 06:24 GMT
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 - 19 May 2004 06:42 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
> 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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.