Monday, November 20, 2006

NetBeans Platform: Branded resources

OK, you've probably been here too: how does one load a Branded resource ? Let's say... the splash screen.

Well, let me tell you the stages you might try after you've found out that it's "org/netbeans/core/startup/splash.gif" :
  • Use the ClassLoader from Lookup to load the resource. What does this do ? It returns the default, non-branded splash.
  • getClass().getResource(). Same as above.
  • new URL(). Wrong !
  • Utilities.loadImage(string). Still wrong.
Of course, the nbres:// protocol might also help (after all it's a NetBeans resource we're talking about) but you know what ? It also fails (with NPE) except for the new URL method.

So ? What is the solution ? Well, it's Utilities.loadImage(string, true) . This is the only one that does the localized/branded woodoo. I'm still not certain why the nbres:// stuff didn't work...


JCD said...


Seems the Utilities.loadImage(string,true) is now deprecated (NB 6.5 RC1)



Emilian Bold said...

Well, the blog post is 2 years old :-)

Take a look at ImageUtilities.loadImage(String,boolean) .

Thanks for dropping by.

Fair Source and the Fair Source Initiative

There's been some uproar about the MongoDB Server Side Public License which tries to prevent cloud vendors like Amazon take all the mon...