Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7388

Re: How to repropagate resolved styles?

From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: How to repropagate resolved styles?
Date 2011-08-25 22:58 +0200
Organization albasani.net
Message-ID <j36d2n$nrm$1@news.albasani.net> (permalink)
References <j33v81$ld8$1@news.albasani.net>

Show all headers | View raw


Jan Burse schrieb:
> The repaint has no effect. The text is shown the same as before.
> But astonishingly when I do the following:
>
>       setEditable(false);
>       setEditable(true);
>
> The resolve parent styles repropagate and the text changes as if
> the resolve parents were logical styles on character level.


I did some diggging. The setEditable() does fire a property change
event with the property name "editable", which in turn calls in 
BasicTextUI the following method:

     /**
      * Flags model changes.
      * This is called whenever the model has changed.
      * It is implemented to rebuild the view hierarchy
      * to represent the default root element of the
      * associated model.
      */
     protected void modelChanged() {
         // create a view hierarchy
         ViewFactory f = rootView.getViewFactory();
         Document doc = editor.getDocument();
         Element elem = doc.getDefaultRootElement();
         setView(f.create(elem));
     }

Can I cause a JTextPane to do a model rebuild as above
without firing a property change event? Problem is
I have to fire two property change events, one
     true -> false
And another:
     false -> true
Because the fire property change method checks whether
the old property value equals the new property value. And
does nothing when they are equal.

So is there a more direct way to cause a model change
than via multiple fire property change events?

Bye

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

How to repropagate resolved styles? Jan Burse <janburse@fastmail.fm> - 2011-08-25 00:50 +0200
  Re: How to repropagate resolved styles? Jan Burse <janburse@fastmail.fm> - 2011-08-25 22:58 +0200

csiph-web