|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.09192 seconds