Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "ram" Subject: Re: false edit trigger Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <2908b4b4-ca46-400b-b595-38cee345ac36@x1g2000prh.googlegroup References: <2908b4b4-ca46-400b-b595-38cee345ac36@x1g2000prh.googlegroup Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 56 Date: Wed, 27 Apr 2011 15:50:21 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303919421 96.60.20.240 (Wed, 27 Apr 2011 10:50:21 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:50:21 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4395 To: comp.lang.java.gui Srik writes: >This is actually false edit trigger, the edit has happened only >programmatically. This question is an FAQ. Sometimes people set a flag to indicate programmatic edits. But maybe this effect also is a sympton showing that something is wrong with the way the application is built. Assume a model with a temperature that is being displayed in two fields +celsius2 and +fahrenheit2. Then, we have four different operations: - SCV: set the celsius value alone - SFV: set the fahrenheit value alone - STC: set the temperature by a celsius value - STF: set the temperature by a fahrenheit value The first two operations only change a single display value, while the last two will change both display values. The last two will invoke the first two, but not the last two themselves (to avoid the recursion mentioned). Possible implementation (simplified): SCV( final double t ){ celsiusField.set( String.valueOf( t )); } SFV( final double t ){ fahrenheitField.set( String.valueOf( t )); } STC( final double t ){ model.setFromCelsius( t ); /* fire change */ } STF( final double t ){ model.setFromFahrenheit( t ); /* fire change */ } model: setFromCelsius( final double t ) { this.t = t; display.SCV( t ); display.SFV( t * 180 / 100 + 32 ); } setFromFahrenheit( final double t ) { this.t =( t - 32 )* 100 / 180; display.SCV(( t - 32 )* 100 / 180 ); display.SFV( t ); } The model uses +SCV2 and +SFV2, not +STC2 and +STF2, so it avoids recursion. However, this suggestion needs model-view separation that is controlled by the application program. It might not work when using Swing components, which are a single unit including /both/ the UI-delegate /and/ the model, because in this case there is only a single change call to change the value, and we want to have two different calls. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24