Use ImageJ toolbar in Swing application

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Use ImageJ toolbar in Swing application

reji
Hi,

I am trying to add ImageJ toolbar to my Swing application. I tried the following after changing the visibility of toolbar.

JPanel jp = new JPanel();
jp.add(IJ.getInstance().toolbar);

But this is giving me NullPointerException.  Any help would be highly appreciated.

thanks,
Reji
Reply | Threaded
Open this post in threaded view
|

Re: Use ImageJ toolbar in Swing application

ctrueden
Hi Reji,

JPanel jp = new JPanel();
> jp.add(IJ.getInstance().toolbar);
>
> But this is giving me NullPointerException.  Any help would be highly
> appreciated.
>

The only opportunity for NullPointerException I see there is that
IJ.getInstance() could be returning null. It does that before the ij.ImageJ
singleton is created. Did you try putting "new ImageJ();" before calling
IJ.getInstance()?

-Curtis

On Mon, Nov 22, 2010 at 4:26 PM, reji <[hidden email]> wrote:

> Hi,
>
> I am trying to add ImageJ toolbar to my Swing application. I tried the
> following after changing the visibility of toolbar.
>
> JPanel jp = new JPanel();
> jp.add(IJ.getInstance().toolbar);
>
> But this is giving me NullPointerException.  Any help would be highly
> appreciated.
>
> thanks,
> Reji
> --
> View this message in context:
> http://imagej.588099.n2.nabble.com/Use-ImageJ-toolbar-in-Swing-application-tp5764666p5764666.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Use ImageJ toolbar in Swing application

dscho
Hi,

On Mon, 6 Dec 2010, Curtis Rueden wrote:

>  Did you try putting "new ImageJ();" before calling IJ.getInstance()?

Or even better: call the constructor with EMBEDDED | NO_SHOW and remember
the instance right away...

        ImageJ ij = new ImageJ(EMBEDDED | NO_SHOW);
        // now do whatever you wanted to do with ij

Ciao,
Dscho