Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Background image on Composite
Background image on Composite [message #723481] Thu, 08 September 2011 16:26 Go to next message
RD  is currently offline RD Friend
Messages: 10
Registered: September 2011
Junior Member
I set the background image of a composite:

composite.setBackgroundImage(image);


The problem is that the image is smaller than the composite, and the image is tiled. How can I change it so that the image is either centered or stretched within the composite? Is there a way to control the image location within the composite?

Thanks.
Re: Background image on Composite [message #723519 is a reply to message #723481] Thu, 08 September 2011 18:00 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Paint the image using a paint listener and change the image size by modifying the image data and getsize method of composite...

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Background image on Composite [message #723600 is a reply to message #723519] Thu, 08 September 2011 22:55 Go to previous messageGo to next message
RD  is currently offline RD Friend
Messages: 10
Registered: September 2011
Junior Member
I tried manipulating the ImageData, but when I call the composite's getsize() I get a Point with 0 width and 0 height.

Point compositeSize = composite.getSize();


Re: Background image on Composite [message #723650 is a reply to message #723600] Fri, 09 September 2011 04:19 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Try using .getClientArea ()

also confirm the layout on the parent of the composite,it should be a Fill or somthing which does not ask the composite what its size should be(assuming u dont have child controls on the composite-if it is not the case then use canvas)

Also Refer this http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet48.java


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Fri, 09 September 2011 06:29]

Report message to a moderator

Previous Topic:Create Control Dynamically
Next Topic:DND in a tree: how to prevent the item being dragged from being selected?
Goto Forum:
  


Current Time: Fri Apr 26 15:27:41 GMT 2024

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

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

Back to the top