Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: How to repropagate resolved styles? Date: Thu, 25 Aug 2011 22:58:56 +0200 Organization: albasani.net Lines: 45 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net MuloY3T5SdMJPVD49eL95Bk9jsoNaebxVsjPQdQGLgsfyt3QJwTJ4tTJB6t/FqFrf2xMaDQI65K0JB5GREcHwgbHPYCwTSmu9QkiBoDkQVee5ktmCcimfDX2j8qASvC2 NNTP-Posting-Date: Thu, 25 Aug 2011 20:59:03 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="fnwDXaZ9IS0uYHJE8cwVQukx/2IS0Feh95+DAgfV4t4ampwIIBXbRJsJ1Ck9WmvhJnTW/d6iV8Zcj0izfKXDUSTPX0GHQs9iLRhWkX8RdbVZoJNmP9Ekx5Iup6spli9Q"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110820 Firefox/6.0 SeaMonkey/2.3.1 In-Reply-To: Cancel-Lock: sha1:5Und43MyRvMC3X2KELHC2c/77j0= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7388 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