Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » org.eclipse.swt.graphics.Image
org.eclipse.swt.graphics.Image [message #490618] Fri, 09 October 2009 12:43 Go to next message
hannes is currently offline hannesFriend
Messages: 12
Registered: October 2009
Location: Germany
Junior Member
Hi,

ive a problem with the following codelines

Image image = new Image(shell.getDisplay(), "./banner.jpg");
Label banner = new Label(composite,SWT.NONE);
banner.setImage(image);


I always get the error message

"java.lang.NoSuchMethodError: org.eclipse.swt.graphics.Image.<init>(Lorg/eclipse/swt/graphics/Device;Ljava/lang/String;)V"


The code works fine on as standalone application but not on RAP.

[Updated on: Fri, 09 October 2009 12:44]

Report message to a moderator

Re: org.eclipse.swt.graphics.Image [message #490627 is a reply to message #490618] Fri, 09 October 2009 13:21 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
You will have to use the XXXDescriptor to create this, e.g.:

public static Image createImage( Display display, URL imageLocation ) {
ImageDescriptor d = ImageDescriptor.createFromURL( imageLocation );
Image ret = d.createImage( display );
return ret;
}


There are ColorDescriptor and FontDescriptor, as well.
Re: org.eclipse.swt.graphics.Image [message #490628 is a reply to message #490618] Fri, 09 October 2009 13:21 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
constructors for Image are not yet supported in RAP (they are
planned for 1.3 [1]). If you would re-compile your code, you would
see compile errors.
To work around this you could use one of the Graphics#getImage()
methods.

HTH
Rüdiger

[1] 284385: Provide non-shared SWT resources
https://bugs.eclipse.org/bugs/show_bug.cgi?id=284385

h4nn3s@inbox.com wrote:
> Hi,
>
> ive a problem with the following codelines
>
>
> Image image = new Image(shell.getDisplay(), "./banner.jpg");
> Label banner = new Label(composite,SWT.NONE);
> placeholder.setImage(image);
>
>
> I always get the error message
>
>
> "java.lang.NoSuchMethodError:
> org.eclipse.swt.graphics.Image.<init>(Lorg/eclipse/swt/graphics/Device;Ljava/lang/String;)V "
>
>
>
> The code works fine on as standalone application but not on RAP.
Re: org.eclipse.swt.graphics.Image [message #490764 is a reply to message #490618] Sat, 10 October 2009 11:33 Go to previous messageGo to next message
hannes is currently offline hannesFriend
Messages: 12
Registered: October 2009
Location: Germany
Junior Member
Hello Rüdiger Herrmann,


do you mean i use the Graphics#getImage() from AWT?
Then how can i use the Image in a SWT Label or other SWT Objects ?

[Updated on: Sat, 10 October 2009 12:26]

Report message to a moderator

Re: org.eclipse.swt.graphics.Image [message #490770 is a reply to message #490618] Sat, 10 October 2009 13:20 Go to previous messageGo to next message
hannes is currently offline hannesFriend
Messages: 12
Registered: October 2009
Location: Germany
Junior Member
I acutally construct the image with

ImageRegistry registry = new ImageRegistry(Display.getCurrent()); 
registry.put("banner", ImageDescriptor.createFromFile(GUI.class, "banner.jpg"));
Image image = registry.get("banner");
Label banner = new Label(composite,SWT.NONE);
banner.setImage(image);


works fine, but if i try to scale the image with

registry.put("banner_rs", new Image(Display.getCurrent(), image.getImageData().scaledTo(450,64)));
image = registry.get("banner_rs");


ill get the following error

Exception in thread "UIThread [1a92ht0o8z644]" java.lang.IllegalStateException: The context has been disposed.
	at org.eclipse.rwt.internal.service.ServiceContext.checkState(ServiceContext.java:154)
	at org.eclipse.rwt.internal.service.ServiceContext.getRequest(ServiceContext.java:82)
	at org.eclipse.rwt.internal.service.ContextProvider.getRequest(ContextProvider.java:129)
	at org.eclipse.rwt.internal.service.ContextProvider.getSession(ContextProvider.java:148)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.setShutdownAdapter(RWTLifeCycle.java:350)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.access$0(RWTLifeCycle.java:347)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:133)
	at java.lang.Thread.run(Unknown Source)



is it another bug, or do i something wrong ?

[Updated on: Sat, 10 October 2009 13:43]

Report message to a moderator

Re: org.eclipse.swt.graphics.Image [message #490824 is a reply to message #490770] Sun, 11 October 2009 15:15 Go to previous message
Benjamin Muskalla is currently offline Benjamin MuskallaFriend
Messages: 338
Registered: July 2009
Senior Member
Hi,

*please* be sure to work against the RAP target platform. The code you
mentioned just won't compile with RAP. And add the -consolelog parameter
to your launch config to see errors that happen during runtime. What you
currently see is only a follow-up error of a degenerated session.

Regards,
Ben

h4nn3s@inbox.com wrote:
> I acutally construct the image with
>
> ImageRegistry registry = new ImageRegistry(Display.getCurrent());
> registry.put("banner", ImageDescriptor.createFromFile(GUI.class, Image
> image = registry.get("banner");
> Image image = registry.get("banner");
> Label banner = new Label(composite,SWT.NONE);
> banner.setImage(image);
>
>
> works fine, but if i try to scale the image with
>
> registry.put("banner_rs", new Image(Display.getCurrent(),
> image.getImageData().scaledTo(450,64)));
> image = registry.get("banner_rs");
>
>
> ill get the following error
>
>
> Exception in thread "UIThread [1a92ht0o8z644]"
> java.lang.IllegalStateException: The context has been disposed.
> at
> org.eclipse.rwt.internal.service.ServiceContext.checkState(S erviceContext.java:154)
>
> at
> org.eclipse.rwt.internal.service.ServiceContext.getRequest(S erviceContext.java:82)
>
> at
> org.eclipse.rwt.internal.service.ContextProvider.getRequest( ContextProvider.java:129)
>
> at
> org.eclipse.rwt.internal.service.ContextProvider.getSession( ContextProvider.java:148)
>
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.setShutdownA dapter(RWTLifeCycle.java:350)
>
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.access$0(RWT LifeCycle.java:347)
>
> at
> org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadCont roller.run(RWTLifeCycle.java:133)
>
> at java.lang.Thread.run(Unknown Source)
>
>
>
> is it another bug, or do i something wrong ?


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Previous Topic:Theming engine based on declarative ui
Next Topic:RAP and JPA
Goto Forum:
  


Current Time: Fri Mar 29 00:24:53 GMT 2024

Powered by FUDForum. Page generated in 0.05803 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top