Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to put a image/icon into my composite instead of button
how to put a image/icon into my composite instead of button [message #466309] Fri, 06 January 2006 09:46 Go to next message
Eclipse UserFriend
Originally posted by: neelakantan_k.infosys.com

how to put a image/icon into my composite instead of button.and do event
handling
Re: how to put a image/icon into my composite instead of button [message #466314 is a reply to message #466309] Fri, 06 January 2006 10:31 Go to previous message
Eclipse UserFriend
Originally posted by: martin.poeschmann.de.gm.com

Thats simple:

-create a Canvas object and put it in your composite
-the painting can be done by:
canvas.addPaintListener( new PaintListener()
{
public void paintControl( PaintEvent e )
{
e.gc.drawImage( background, 0, 0 );
}
});
-you get the image with:
Bundle bundle = Platform.getBundle("<your-plugin-package>");
URL url = Platform.find(bundle, new Path("<path-within-plugin>"));

try
{
URL resUrl = Platform.resolve( url );
String path = resUrl.getPath();
String alias = path + "<image-name>";
background = new Image( parent.getDisplay(), alias );
}
catch( IOException ex )
{
ex.printStackTrace();
}
-implement a MouseListener and add it to the canvas-object
(addMouseListener)
-put your action code into "public void mouseUp( MouseEvent e )" of your
MouseListener

Hope that helps,
Martin Poeschmann
Previous Topic:editor plugin color preferences question
Next Topic:Problem with Tree under Windows
Goto Forum:
  


Current Time: Thu Dec 26 16:35:29 GMT 2024

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

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

Back to the top