Archived

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

[java] Working with JEditorPanes

This topic is 4958 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

I''ve been trying to get a JEditorPane to be able to display multiple paragraphs and/or HTML from a string bu there doesn''t seem to be a way to do this from what i could find on suns website and searching this forum. The constructors and set methods that can do this want either a URL or a filename but I wanted to be able to display formatting with text I put in on the fly. Eg. I load my Characters when my game starts and they have an introduction for that character on a single line in the characters file, this is just to make file parsing simpler (and JEditorPanes don''t seem to be able to handle multiple lines anyway). Then I want to be able to add paragraph tags to the introduction so that it''s displayed correctly. Other formatting features would be nice but paragraphs are the main one. One possible solution I may have found is to use EditorKits, but I''m not sure if it would be worth the hassle to bother with this or if it would apply without loading a document from a file anyway. Another possability I thought of was to create a class that can parse the string and create a dynamic stack of JEditorPane''s but this would look pretty rough and probably chew up alot of memory. So, does anyone have any suggestions for this?

Share this post


Link to post
Share on other sites