Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Display a image
Display a image [message #480435] Mon, 17 August 2009 07:11 Go to next message
Antonio is currently offline AntonioFriend
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 #480438 is a reply to message #480435] Mon, 17 August 2009 07:24 Go to previous messageGo to next message
Aleksandar Pavlov is currently offline Aleksandar PavlovFriend
Messages: 79
Registered: July 2009
Member
Antonio De Curtis wrote:
>I think the problem is i don't refresh the
> display or the shell can you help me?


Maybe the layout() method will help :)
Greetings
Re: Display a image [message #480448 is a reply to message #480438] Mon, 17 August 2009 08:00 Go to previous messageGo to next message
Antonio is currently offline AntonioFriend
Messages: 39
Registered: July 2009
Member
"Aleksandar Pavlov" <a.pavlov@bers-soft.com> ha scritto nel messaggio
news:h6b0jm$d57$1@build.eclipse.org...
> Antonio De Curtis wrote:
>>I think the problem is i don't refresh the
>> display or the shell can you help me?
>
>
> Maybe the layout() method will help :)
> Greetings

Hi Aleksander, thanks for your idea but don't work.
i try, s.draw() but i don't have nothing.

regads
Antonio
Re: Display a image [message #480542 is a reply to message #480435] Mon, 17 August 2009 14:58 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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
>
Re: Display a image [message #480599 is a reply to message #480542] Mon, 17 August 2009 19:41 Go to previous messageGo to next message
Antonio is currently offline AntonioFriend
Messages: 39
Registered: July 2009
Member
Hi Grant thanks for your answer but don't work well, infact i have the equal
problem
now i write this:
.........
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) {
e.gc.drawImage(image, 50, 50);
e.gc.dispose();
} }); //

}
catch(FileNotFoundException e1)
{
e1.printStackTrace();
}
Re: Display a image [message #482020 is a reply to message #480599] Tue, 25 August 2009 07:13 Go to previous message
Antonio is currently offline AntonioFriend
Messages: 39
Registered: July 2009
Member
"Antonio De Curtis" <adecurtis99@yahoo.it> ha scritto nel messaggio
news:h6cbpo$c2u$1@build.eclipse.org...
> Hi Grant thanks for your answer but don't work well, infact i have the
> equal problem
> now i write this:
> ........
> 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) {
> e.gc.drawImage(image, 50, 50);
> e.gc.dispose();
> } }); //
>
> }
> catch(FileNotFoundException e1)
> {
> e1.printStackTrace();
> }


Hi guys i resolve the problem, infact i use canvas.redraw() and all work
fine :)

thanks for all.
Antonio
Previous Topic:Export dll
Next Topic:Add scroll bars to composite
Goto Forum:
  


Current Time: Wed Feb 05 11:45:25 GMT 2025

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

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

Back to the top