Where should I dispose the Image used by Label? [message #152762] |
Tue, 05 October 2004 03:52 |
Eclipse User |
|
|
|
Originally posted by: wangwei.org.gmail.com
Hi, all!
If I use a image in a Draw2D Label, where should I dispose it?
I tried to override the paintFigure() method like this:
Image image = new Image(...);
label.setIcon(image);
super.paintFigure(g);
image.dispose();
but got an exception:
"java.lang.IllegalArgumentException: Argument not valid"
Thanks!
regards, wangwei
|
|
|
Re: Where should I dispose the Image used by Label? [message #152905 is a reply to message #152762] |
Tue, 05 October 2004 20:56 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
You should probably keep the image around for the duration of the editor's
existence, or at least as long as the figure exists. Figures are not
disposed, but its editpart is guaranteed to be deactivated, so you can get
rid of the Image at that point. You may want to look into creating a
registry or utility for sharing images across figures/editparts/editors.
"WANG Wei" <wangwei.org@gmail.com> wrote in message
news:cjt5i0$4ic$1@eclipse.org...
> Hi, all!
>
> If I use a image in a Draw2D Label, where should I dispose it?
>
> I tried to override the paintFigure() method like this:
>
> Image image = new Image(...);
> label.setIcon(image);
>
> super.paintFigure(g);
>
> image.dispose();
>
> but got an exception:
> "java.lang.IllegalArgumentException: Argument not valid"
>
> Thanks!
>
> regards, wangwei
>
>
|
|
|
Re: Where should I dispose the Image used by Label? [message #152989 is a reply to message #152905] |
Wed, 06 October 2004 11:39 |
Eclipse User |
|
|
|
Originally posted by: wangwei.org.gmail.com
Thank you!
So I think I could override the function EditPart.deactivate(),
Using a registry is also a good idea, and I have created one.
"Randy Hudson" <none@us.ibm.com> wrote in message
news:cjv1gg$s63$1@eclipse.org...
> You should probably keep the image around for the duration of the editor's
> existence, or at least as long as the figure exists. Figures are not
> disposed, but its editpart is guaranteed to be deactivated, so you can get
> rid of the Image at that point. You may want to look into creating a
> registry or utility for sharing images across figures/editparts/editors.
>
> "WANG Wei" <wangwei.org@gmail.com> wrote in message
> news:cjt5i0$4ic$1@eclipse.org...
> > Hi, all!
> >
> > If I use a image in a Draw2D Label, where should I dispose it?
> >
> > I tried to override the paintFigure() method like this:
> >
> > Image image = new Image(...);
> > label.setIcon(image);
> >
> > super.paintFigure(g);
> >
> > image.dispose();
> >
> > but got an exception:
> > "java.lang.IllegalArgumentException: Argument not valid"
> >
> > Thanks!
> >
> > regards, wangwei
> >
> >
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03645 seconds