Splash Screen Client Swing [message #520926] |
Mon, 15 March 2010 19:33 |
Eclipse User |
|
|
|
People asking how to change the splash screen of Swing-Scout-Clients.
'DefaultSwingEnvironment.createIconUIResource("splash")' is called to
create the splash screen. The fist way to change the default splash is
to override this method in your Environment implementation. An other one
quite easier is to put a 'splash.(png|gif|jpg)' in the
'resources/icons/'f folder of your applications swing bundle (e.g.
org.eclipse.scout.sample.ui.swing).
Enjoy
andy
|
|
|
|
|
|
|
|
Re: Splash Screen Client Swing [message #990757 is a reply to message #990558] |
Fri, 14 December 2012 06:44 |
|
Hi Urs
The NullPointerException you get is because the variable m_iconLocator is not set until showGUI() is called - which is after interceptUIDefaults(). So you cannot use the getIcon() method to load your image.
But the solution is not that far. Have a look at the code of org.eclipse.scout.rt.ui.swing.inject.UIDefaultsInjector.
...
putIfUndefined(defaults, "Splash.icon", getSplashUIResource());
...
The method getSplashUIResource() actually implements the default behaviour Andreas mentioned in his post (put an image called "splash" in your plug-in). It uses different methods to find and load such an image.
I suggest that you try loading your icon with the Activator's iconLocator (which should be ready at that time): org.eclipse.scout.rt.ui.swing.Activator.getIcon(String)
Your snippet (in your SwingEnvironment) would then look like:
public void interceptUIDefaults(UIDefaults defaults) {
super.interceptUIDefaults(defaults);
defaults.put("Splash.icon", createIconUIResource("your_custom_splash"));
}
protected IconUIResource createIconUIResource(String resourceSimpleName) {
Icon icon = Activator.getIcon(resourceSimpleName);
if (icon != null) {
return new IconUIResource(icon);
}
else {
return null;
}
}
Note that I copied the method createIconUiResource from the class UIDefaultsInjector. Try creating your own injector class, then you can use the method directly.
|
|
|
Re: Splash Screen Client Swing [message #991054 is a reply to message #990757] |
Mon, 17 December 2012 08:45 |
Urs Beeli Messages: 573 Registered: October 2012 Location: Bern, Switzerland |
Senior Member |
|
|
Beat,
Thanks for your response. I've tried this approach, however, I can't quite get it to work yet.
First of all, my swing client plugin's Activator does *not* have a getIcon() method. Its signature is
public class Activator implements BundleActivator{
and the only methods it has are start(), stop() and getDefault().
To work around this, I've tried modifying SwingEnvironment.createIconUIResource() as follows:
private IconUIResource createIconUIResource(String resourceSimpleName) {
Icon icon = org.eclipse.scout.rt.ui.swing.Activator.getIcon(resourceSimpleName);
if (icon != null) {
return new IconUIResource(icon);
}
else {
return null;
}
}
However, when running my client, I just get a grey rectangle instead of the splash screen and a line in the console saying:
!MESSAGE org.eclipse.scout.rt.ui.swing.SwingIconLocator.warnImageNotFound(SwingIconLocator.java:141) could not find image 'Splash'
So, for some reason, my splash screen image cannot be found (despite there being a Splash.png file in *.ui.swing/resources/icons).
Do I need something else to allow the icon resolution? Or is my attempt at directly accessing the org.eclipse.scout.rt.ui.swing.Activator what is causing this problem?
I'd appreciate any hints on where I go wrong.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04703 seconds