Article View: borland.public.jbuilder.java.swing
Article #8460Displaying Span Tag in JTextPane
From: Nicki Helfrich
Date: Thu, 24 Aug 2000 00:00
Date: Thu, 24 Aug 2000 00:00
65 lines
2977 bytes
2977 bytes
Hello everybody out there,
i have a problem with displaying some text that has the SPAN Tag
with the CLASS-Attribute set in the JTextPane.
I try to build a littel HTML-WYSIWYG-Editor that is
able of some basic features like
setting text bold and italic and
changing the font size.
I want to set the Font Size using the SPAN - Tag with
the CLASS-Attribute like recommended by the W3C - Spec.
To do so, i subclassed the HTMLEditor Kit and implemented
a inner class to set the Attribute like this...
public static class SpanClassAction extends StyledTextAction
{
String sClass;
public SpanClassAction(String sName, String sClassValue)
{
super(sName);
this.sClass = sClassValue;
}
public void actionPerformed(ActionEvent e)
{
JEditorPane editor = getEditor(e);
if (editor != null)
{
SimpleAttributeSet sasClass = new SimpleAttributeSet();
SimpleAttributeSet sasSpan = new SimpleAttributeSet();
sasClass.addAttribute(HTML.Attribute.CLASS,sClass);
sasSpan .addAttribute(HTML.Tag.SPAN,sasClass);
setCharacterAttributes(editor, sasSpan, false);
editor.requestFocus();
}
}
}
I also load the proper StyleSheet File and when i call the action
from some button with having some text marked in the Editor it
becomes displayed properly as specified in the Style Sheet File.
And when I print the HTML-Text with
String RawHTML = Editor.getText();
...
it contains the SPAN-Tag with the CLASS-Attribute in well formed HTML.
BUT...
when I set the Text in the Editor with the
Editor.setText(RawHTML);
Method it seems like the Parser or whatever does not understand the Tag
and completely ignores it.
It is not contained in the Document Structure provided by the
HTMLDocument-Class.
The Attributes are simply not set and therefor the Text is displayed as
plain text.
The only thing indicating that there is SOMETHING is an extra Space where
the SPAN
start and end Tags are, and those are contained in the Doc. Structure.
Does anybody have the same problem, or even better... had that problem and
solved it ?
...and... does anybody know some free or commercial java component that is
able of properly doing basic formating features ?
Greetings and a nice day...
Nicki Helfrich
Technical Details
Message-ID:
<8o2ojp$9nbev$1@ID-45838.news.cis.dfn.de>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,331d56e7d943a09f,start
X-Google-Attributes: gid111d45,public
X-Google-Thread: 10568c,331d56e7d943a09f,start
X-Google-Attributes: gid10568c,public
X-Google-Thread: fb99b,331d56e7d943a09f,start
X-Google-Attributes: gidfb99b,public
From: "Nicki Helfrich" <hel{NOSPAM}frich@sitewaerts.de>
Subject: Displaying Span Tag in JTextPane
Date: 2000/08/24
Message-ID: <8o2ojp$9nbev$1@ID-45838.news.cis.dfn.de>
X-Deja-AN: 661878092
X-Trace: fu-berlin.de 967108025 10202591 212.227.111.39 (16 [45838])
X-MSMail-Priority: Normal
X-Priority: 3
Newsgroups: borland.public.jbuilder.java.swing,cz.comp.lang.java,de.comp.lang.java
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700