I had this same issue and ended up creating a new object every time. But, what if "setTabData" just checked for !equals()? And then have ButtonData implement "equals()" with "equals()" checks on the text, icon and userData? The "equals()" for "text" (String) does the right thing, icon (Image) just does reference equality, as does the default for "userData" (often null anyway).
But, having "setTabData" always do the notify might not be a bad thing, although you might have to weigh the probability that the objects really are the same vs. the cost of doing an unnecessary repaint. Roger Whitcomb | Architect, Engineering | [email protected] | Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 | USA +1 650-587-5596 | fax: +1 650-587-5550 -----Original Message----- From: Edvin Syse [mailto:[email protected]] Sent: Tuesday, June 14, 2011 2:05 PM To: [email protected] Subject: Re: Update TabData - supposed to call listeners manually? Den 14.06.2011 23:01, skrev Greg Brown: >>> > b) A logical equality check may simply be unnecessary overhead. If a caller has explicitly invoked a setter for a property, we might reasonably assume that the caller genuinely wants to update the property's value. Calling an equals() method on the value in that case just incurs a needless performance hit. > > What do you think? That's exactly my though! "If you called it, you probably meant it." And the equals check is unnecessary overhead as you say :) -- Edvin
