SWTResourceManager

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

SWTResourceManager

Postby Marc Adams » Thu Sep 14, 2006 10:00 am

Eric (or anyone else who knows),

The SWTResourceManager class that is created when using window designer - does it cache and dispose of images automagically?

It probably seems like a rudimentary issue, but I'm wondering what the best way to use it.

Should I always use SWTResourceManager.getImage(RelativeClass.class, "icons/img.gif");

or should I create a constant class that calls SWTResourceManager.getImage(RelativeClass.class, "icons/img.gif");
for each image I might need.

Or even further, create a constant class that has Strings that represent the image (public static final String IMG_FILE = "icons/img.gif";) and then wherever I need an image use the SWTResourceManager call used above with the constant value for the image?

What is the best practice in this instance?

I appreciate it!
Marc Adams
 
Posts: 7
Joined: Wed Jun 28, 2006 7:48 am

Re: SWTResourceManager

Postby Eric Clayberg » Thu Sep 28, 2006 6:56 pm

Marc Adams wrote:The SWTResourceManager class that is created when using window designer - does it cache and dispose of images automagically?

See the class comment on the SWTResourceManager class. Images are cached, but you need to call dispose() when your app is shutting down.

Marc Adams wrote:What is the best practice in this instance?

I'm not aware of any. Use whochever approach you like best.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest