• Advertisement

Archived

This topic is now archived and is closed to further replies.

[java] textarea

This topic is 6549 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to create a java applet to serve as the client to a program I am making. I want to be able to do like Yahoo and other chat places do their text. It looks to me like they place their text inside a textarea, but how do they get other attributes? for example, choosing different fonts, and different colors, and font sizes, background, pictures, etc. How could I create a similar "textarea" for use in my project.

Share this post


Link to post
Share on other sites
Advertisement
I think this is a job for styled documents.
http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
I''ve never actually done anything with them but I think that''s what you need. There is an example that comes with the jdk in which you can change the font and color of text, and insert images.

Share this post


Link to post
Share on other sites
I may have overlooked it, but I couldnt find the information
I needed on the URL you gave.

It seems like it would be pretty simple, but I just cant seem to find source so I can change font attributes [color, etc] and insert pictures inside a textarea.

maybe they use something other than textarea?

Share this post


Link to post
Share on other sites
You''re not looking for textarea stuff. You should be looking for styled document stuff. There''s an example in the jdk distributuion
\demo\jfc\StylePad\
java -jar Stylepad.jar

I''m sure that is for what you are looking, right?

Share this post


Link to post
Share on other sites
couldnt look at it tonite, but if Im not mistaken, swing is for Java 1.2 and greater, I was just curious which browsers support Java 1.2 and greater?

Share this post


Link to post
Share on other sites
Well, none right now. That''s why we have the Plug-In available for most platforms. Now, most probably, future versions of the browsers will support JDK 1.2, but until then you have to learn how to deal with the nuances of the Plug-In, which in my opinion, is still new technology and has plenty of problems.

JoeG

Share this post


Link to post
Share on other sites
then how does Yahoo.com chat do their java chat clients?

They have colored text, and images inside their "textarea".

There must be a way to do this under Java 1.0 then right?

Share this post


Link to post
Share on other sites
What if I tried to create my own textarea from the classes that textarea get its inheritance from? would that be possible, and then I could add in colored text?

Somebody suggested using a Canvas to impersonate a textarea, but that way I could do anything to it, colored text, pictures, anything. How would I implement this?

Share this post


Link to post
Share on other sites
I don''t imagine that there would be any problem with you just using the javax.swing.text package and just including it in your distribution. Most of the stuff you need are interfaces, and the concrete implementations directly extend java.lang.object. If not, you can still look at the source for ideas on what methods to use if you are going to extend textarea yourself.

Share this post


Link to post
Share on other sites
Just run java -verbose yourApp.class and capture the output. What you see is a list of all the classes that you''re app loaded. Finding these classes in the class hierarchy is an entirely different problem though.

Share this post


Link to post
Share on other sites

>I don''t imagine that there would be any problem with you
>just using the javax.swing.text package and just including
>it in your distribution.

The main reason I dont want to use Java 1.1, 1.2, 2.0, or swing is because it is going to be an applet. I need it to be small and use Java 1.0

I''ll try and see if I can find the appropriate classes
so I can extend textarea to include colored fonts and images.

thanx for all the advice and replies.

Share this post


Link to post
Share on other sites
If you''re using 1.0 there''s not going to be any API or class that you can use, you''re gonna have to code your own component. Good luck hadling events.

Share this post


Link to post
Share on other sites
Actually java1.1 is supported by the major browsers. The event handling there is a lot more nicer than it was with java1.0

JoeG

Share this post


Link to post
Share on other sites
well, I''m beginning coding it today...

Its going to have a canvas, and a scrollbar.

The part Im trying to figure out is this:
I am going to need to know the total height of the
"textarea" information, so I can deal with the scrollbar.

but this isnt as easy as it sounds. because Im going to be
using different fonts, and each font takes up different amount of space. some are fixed-width, and some arent.
And then if I add in images, I''ll hafta add them into figureing out the hieght.

what should I have the "textarea" contents stored in?
How should I store it, so I can store the color of different words and images and such?

Share this post


Link to post
Share on other sites

  • Advertisement