🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #12599

Re: Changing the Style of a HTML Document

#12599
From: Steve Waters
Date: Thu, 10 Dec 1998 00:00
71 lines
3065 bytes
Hi Brett,

I presume that you are trying to select some text and then make it bold, or what ever, if so I
will try to find the code that i wrote that does this.

But let me add that this package, the HTML, is not very stable and this will be the first hurdle
of many, even sun say dont try to use this for "development". This package i feel will undergo
many changes as it fixed.

You could just the hotjava bean, i have and its actually quite good, and robust.

Regards
Steve


Brett Walker wrote:

> Hi,
>
> I am trying to change the style of a select of HTML. The following code:
>
>       HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
>       MutableAttributeSet s = new SimpleAttributeSet();
>       s.addAttribute(StyleConstants.NameAttribute, HTML.Tag.B);
>       int start = editorPane.getSelectionStart();
>       int end = editorPane.getSelectionEnd();
>       doc.setCharacterAttributes(start,end,s,false);
>
> gives
>
> Exception occurred during event dispatching:
> Can't build a b, LeafElement(b) 179,195
> at
> javax.swing.text.html.HTMLEditorKit$HTMLFactory.create(HTMLEditorKit.java:705)
>
> at
> javax.swing.text.ParagraphView.updateLogicalChildren(ParagraphView.java:825)
>
> at javax.swing.text.ParagraphView.changedUpdate(ParagraphView.java:890)
> at javax.swing.text.BoxView.changedUpdate(BoxView.java:502)
> at javax.swing.text.BoxView.changedUpdate(BoxView.java:502)
> at
> javax.swing.plaf.basic.BasicTextUI$RootView.changedUpdate(BasicTextUI.java:1180)
>
> at
> javax.swing.plaf.basic.BasicTextUI$UpdateHandler.changedUpdate(BasicTextUI.java:1398)
>
> at
> javax.swing.text.AbstractDocument.fireChangedUpdate(AbstractDocument.java:184)
>
> at
> javax.swing.text.DefaultStyledDocument.setCharacterAttributes(DefaultStyledDocument.java:355)
>
> at Wave.EditWindow$BoldAction.actionPerformed(EditWindow.java:578)
>
> However the following code
>
>       HTMLDocument doc = (HTMLDocument) editorPane.getDocument();
>       MutableAttributeSet s = new SimpleAttributeSet();
>       // s.addAttribute(StyleConstants.NameAttribute, HTML.Tag.B);
>       StyleConstants.setBold(s, true);
>       int start = editorPane.getSelectionStart();
>       int end = editorPane.getSelectionEnd();
>       doc.setCharacterAttributes(start,end,s,false);
>
> doesn't throw the exception, it adds an attribute of Bold that ins't
> translated into HTML.
>
> Thanks for any help or suggestions.
>
> Cheers
Technical Details
Message-ID: <36707569.7756345@bellsouth.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <364B7997.A0F37C98@ozemail.com.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,b92d240cfea8445
X-Google-Attributes: gid111d45,public
From: Steve Waters <steve_w@bellsouth.net>
Subject: Re: Changing the Style of a HTML Document
Date: 1998/12/10
Message-ID: <36707569.7756345@bellsouth.net>
X-Deja-AN: 421018329
Content-Transfer-Encoding: 7bit
References: <364B7997.A0F37C98@ozemail.com.au>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing