Display a image [message #480435] |
Mon, 17 August 2009 07:11 |
Antonio Messages: 39 Registered: July 2009 |
Member |
|
|
Hi to all, thanks for yours answers.
I have this problem i want to create a RCP that i can see a image,
i write this:
final Display d = new Display();
final Shell s = new Shell(d);
s.setText("Image");
s.setLayout(new FillLayout());
final Button bg13_2;
bg13_2 = new Button(s, SWT.PUSH);
bg13_2.setBounds(180, 20, 160, 20);
bg13_2.setText("See Image");
bg13_2.addSelectionListener (new SelectionAdapter () {
public void widgetSelected (SelectionEvent e)
{
try{
final Image image=new Image(d,new FileInputStream("c:/nap/img3.bmp"));
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
GC gc = new GC(canvas);
gc.drawImage(image, 50, 50);
gc.dispose();
}
}); //
}
catch(FileNotFoundException e1)
{
e1.printStackTrace();
}
}
});
this software work well but if i push the button i don't see image but if i
push the button, i reduce a icon the form and later i expand the form i can
see the image. I think the problem is i don't refresh the display or the
shell can you help me?
best regads
Antonio
|
|
|
|
|
Re: Display a image [message #480542 is a reply to message #480435] |
Mon, 17 August 2009 14:58 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
In your paintControl() implemention you should not be creating a new GC to
draw the Image on, you should use e.gc instead. Does changing this help?
Grant
"Antonio De Curtis" <adecurtis99@yahoo.it> wrote in message
news:h6avrb$d7$1@build.eclipse.org...
> Hi to all, thanks for yours answers.
> I have this problem i want to create a RCP that i can see a image,
> i write this:
> final Display d = new Display();
>
> final Shell s = new Shell(d);
>
> s.setText("Image");
>
> s.setLayout(new FillLayout());
>
> final Button bg13_2;
>
> bg13_2 = new Button(s, SWT.PUSH);
>
> bg13_2.setBounds(180, 20, 160, 20);
>
> bg13_2.setText("See Image");
>
> bg13_2.addSelectionListener (new SelectionAdapter () {
>
>
> public void widgetSelected (SelectionEvent e)
>
> {
>
> try{
>
>
> final Image image=new Image(d,new FileInputStream("c:/nap/img3.bmp"));
>
>
> canvas.addPaintListener(new PaintListener() {
>
> public void paintControl(PaintEvent e) {
>
> GC gc = new GC(canvas);
>
> gc.drawImage(image, 50, 50);
>
> gc.dispose();
>
>
> }
>
> }); //
>
> }
>
> catch(FileNotFoundException e1)
>
> {
>
> e1.printStackTrace();
>
> }
>
>
> }
>
> });
>
>
>
> this software work well but if i push the button i don't see image but if
i
> push the button, i reduce a icon the form and later i expand the form i
can
> see the image. I think the problem is i don't refresh the display or the
> shell can you help me?
>
> best regads
>
> Antonio
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04321 seconds