Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to add background Image in a StyledText
How to add background Image in a StyledText [message #466931] Thu, 19 January 2006 14:34 Go to next message
Eclipse UserFriend
Originally posted by: mengfanjun.gmail.com

I would like to add a background image in StyledText,how to do this.

Thanks!
Re: How to add background Image in a StyledText [message #466950 is a reply to message #466931] Thu, 19 January 2006 19:38 Go to previous messageGo to next message
Adam Kumpf is currently offline Adam KumpfFriend
Messages: 14
Registered: July 2009
Junior Member
dali wrote:

> I would like to add a background image in StyledText,how to do this.

> Thanks!

I'm not an expert, but I think this should do the trick.



Display d = new Display(); // you probably already have a display
Shell s = new Shell(d); // you probably already have a shell

StyledText st = new StyledText(s,SWT.NONE);
st.setText("some funny text\n to try\t\t Weee!");
st.pack(); // automatically set width and height to fit text,
// you may want to change that.
st.setLocation(10,10); // set the x,y location
Image myImage = new Image(st.getDisplay(),"enter file location here...");
st.setBackgroundImage(myImage);



Hope that helps.

Best Regards,
Adam Kumpf
kumpf@mit.edu
Re: How to add background Image in a StyledText [message #467311 is a reply to message #466950] Sat, 28 January 2006 18:38 Go to previous message
Adam Kumpf is currently offline Adam KumpfFriend
Messages: 14
Registered: July 2009
Junior Member
Adam Kumpf wrote:

> dali wrote:

>> I would like to add a background image in StyledText,how to do this.

>> Thanks!

> I'm not an expert, but I think this should do the trick.



> Display d = new Display(); // you probably already have a display
> Shell s = new Shell(d); // you probably already have a shell

> StyledText st = new StyledText(s,SWT.NONE);
> st.setText("some funny textn to trytt Weee!");
> st.pack(); // automatically set width and height to fit text,
> // you may want to change that.
> st.setLocation(10,10); // set the x,y location
> Image myImage = new Image(st.getDisplay(),"enter file location here...");
> st.setBackgroundImage(myImage);



> Hope that helps.

> Best Regards,
> Adam Kumpf
> kumpf@mit.edu


I recently needed to take my own advice and add a background image to
StyledText.. But I ran in to the problem you must have been facing. The
normal ways of setting the background image do not work with the
StyledText object because it has other background painters that paint over
the image. I've been trying to find a way to stop them, but I haven't had
much luck.

Does anyone know how to turn off all of the background painters in a
StyledText object such that the setBackgroundImage(Image) actually sets
the background image? I can see it flicker the image for about a single
frame when I open the window, but then the image is quickly covered by a
white fill of some kind.

Thanks!

-Adam Kumpf
Previous Topic:Preferences Dialog Source Code
Next Topic:Ability to create SWT Font / FontData objects from files or InputStreams
Goto Forum:
  


Current Time: Sat May 25 12:51:03 GMT 2019

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

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

Back to the top