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 / GUI / January 2004

Tip: Looking for answers? Try searching our database.

JTextPane + HTMLEditorKit = How to get HTML?

Thread view: 
Alexandre Campos Hermida - 14 Jan 2004 11:22 GMT
 Hello,

I was wondering have HTML text behind a JTextPane, but inserting
information as StyledText. So, I used the HTMLEditorKit and StyledText
as below:

_logView = new JTextPane();
_logView.setEditorKit(new HTMLEditorKit());
_logViewDoc = _logView.getStyledDocument();
_logView.getCaret().setSelectionVisible(true);
setDocStyles(_logViewDoc);
try {
_logViewDoc.insertString(0,"TESTING;",_logViewDoc.getStyle("regular"));
_logViewDoc.insertString(_logViewDoc.getLength(),"COMMAND",_logViewDoc.getStyle("command"));
}catch(BadLocationException e) {}

The problem is that I need the HTML to print the document but when I try
to get it by using _logView.getText(); statement it returns the HTML
TAGs but doesn't return the text I inserted (see below). Am I doing
something wrong? Or maybe I am missing something?

<html>
<head>
<style type="text/css">
<!--
error { color: #ff0000 }
regular { font-size: 3; color: #000000; font-family: Courier }
command { color: #0000ff }
-->
</style>
</head>
<body>
<p>
<font color="#000000" face="Courier" size="3"><regular>
</font><font color="#0000ff"><command>
</font> </p>
Andrew Thompson - 14 Jan 2004 21:15 GMT
Please change your newsreader settings
to post to usenet forums in plain text _only_
Alexandre.  While you are at it, set the line wrap
to no more than 75 chars..

The text size you use is so small I cannot read it.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site


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



©2009 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.