Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Drawing text on a picture using GC
Drawing text on a picture using GC [message #442810] Mon, 13 September 2004 19:34 Go to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
I'm trying to draw some text on a picture and its not showing up. I'm sure
I'm just doing something stupid. The code is below. Thanks.

Image leftImage = ResourceManager.getImage(TestComposite.class, "left.gif");
final Label label = new Label(this, SWT.NONE);

GC gc = new GC(leftImage);
Font font = new Font(Display.getCurrent(),"Arial",12,SWT.NONE);

gc.setForeground(new Color(Display.getCurrent(),91,123,176));
gc.drawString("Hello World",1,1,true);
label.setImage(leftImage);
Re: Drawing text on a picture using GC [message #442882 is a reply to message #442810] Tue, 14 September 2004 10:16 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Chris <schtoo@schtoo.com> wrote:

Ha, I know this class - ResourceManager. ;-)
Here is a little changed code that I've used to test.
Notice that main change is gc.dispose().

Image leftImage = ResourceManager.getImage(TestImageLabel.class, "images/left.png");
final Label label = new Label(shell, SWT.NONE);

GC gc = new GC(leftImage);
Font font = new Font(Display.getCurrent(),"Arial",34,SWT.BOLD);
gc.setFont(font);

gc.setForeground(new Color(Display.getCurrent(),91,123,176));
gc.drawString("Hello World",1,1,true);
gc.dispose();
label.setImage(leftImage);


> I'm trying to draw some text on a picture and its not showing up. I'm sure
> I'm just doing something stupid. The code is below. Thanks.

> Image leftImage = ResourceManager.getImage(TestComposite.class, "left.gif");
> final Label label = new Label(this, SWT.NONE);

> GC gc = new GC(leftImage);
> Font font = new Font(Display.getCurrent(),"Arial",12,SWT.NONE);

> gc.setForeground(new Color(Display.getCurrent(),91,123,176));
> gc.drawString("Hello World",1,1,true);
> label.setImage(leftImage);



--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)


Konstantin Scheglov,
Google, Inc.
Re: Drawing text on a picture using GC [message #442895 is a reply to message #442882] Tue, 14 September 2004 18:06 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Hah. Yeah I'm using the SWTDesigner. Thanks for the help.

-Chris

"Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
news:3cZ63PkmEHA.3588@fairy.ao.nlmk...
> Chris <schtoo@schtoo.com> wrote:
>
> Ha, I know this class - ResourceManager. ;-)
> Here is a little changed code that I've used to test.
> Notice that main change is gc.dispose().
>
> Image leftImage = ResourceManager.getImage(TestImageLabel.class,
> "images/left.png");
> final Label label = new Label(shell, SWT.NONE);
>
> GC gc = new GC(leftImage);
> Font font = new Font(Display.getCurrent(),"Arial",34,SWT.BOLD);
> gc.setFont(font);
>
> gc.setForeground(new Color(Display.getCurrent(),91,123,176));
> gc.drawString("Hello World",1,1,true);
> gc.dispose();
> label.setImage(leftImage);
>
>
>> I'm trying to draw some text on a picture and its not showing up. I'm
>> sure
>> I'm just doing something stupid. The code is below. Thanks.
>
>> Image leftImage = ResourceManager.getImage(TestComposite.class,
>> "left.gif");
>> final Label label = new Label(this, SWT.NONE);
>
>> GC gc = new GC(leftImage);
>> Font font = new Font(Display.getCurrent(),"Arial",12,SWT.NONE);
>
>> gc.setForeground(new Color(Display.getCurrent(),91,123,176));
>> gc.drawString("Hello World",1,1,true);
>> label.setImage(leftImage);
>
>
>
> --
> SY, Konstantin.
> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
Previous Topic:How to determine a system font
Next Topic:DnD Target accepting numerous types?
Goto Forum:
  


Current Time: Fri Apr 19 11:21:56 GMT 2024

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

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

Back to the top