Login  Register

ImageJ Applet problem running my code and opening images

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

ImageJ Applet problem running my code and opening images

thehobbit
6 posts
Hello everyone,

I'm trying to run my JAVA code as an applet using also ImageJ API, but it doesn't work.
I even have problem showing a simple image. Here is an example:

public class ImageJApplet extends Applet {

        /** Starts ImageJ if it's not already running. */
    public void init() {
    ImageJ ij = IJ.getInstance();
      if (ij==null || (ij!=null && !ij.isShowing()))
                        new ImageJ(this);

    ImagePlus imp = new ImagePlus("http://osasapere.it/wp-content/uploads/2011/06/dna_500.jpg");
       
        imp.show();
       
    }
   
    public void destroy() {
    ImageJ ij = IJ.getInstance();
    if (ij!=null) ij.quit();
    }

}

The main istance of imageJ starts, but the image does not start at all.
I have more code to run as an applet, like:

            SelectionTool st = new SelectionTool();
            st.run("");

This code, for example, shows some JAVA button I made which run some imageJ API and so on, and it works when I run it in Eclipse, but fails to start as an applet.

A "funny" thing I noticed is this: when I try to use this applet http://rsb.info.nih.gov/ij/applet2/ it does not show the images passed as parameters as it says, but starts only the main instance of imageJ.
So, I don't know if the problem is my browser; I use Chrome.

Can someone help me please?

Thank you in advance
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Applet problem running my code and opening images

thehobbit
6 posts
This post was updated on Nov 13, 2012; 1:38pm.
Sorry, I forgot to post the html code I use to run the applet, if it can help:

<html>
<head>
<title>ImageJA Applet</title>
</head>
<body bgcolor=gray>

<h1>ImageJ embedded in a website</h1>

<applet codebase="."
	code="ij.ImageJApplet.class" archive="ij.jar"
	width=750 height=550
	security=all-permissions>
<param name=url1 value=images/danbo1.jpg>
<param name=url2 value=images/danbo2.jpg>
</applet>

</body>
</html>


or also this:

<!DOCTYPE html>
<html>
<body>
<APPLET code=ij.ImageJApplet.class width=750 height=550 archive="ij.jar">
<PARAM NAME="code" VALUE="ij.ImageJApplet.class">
<PARAM NAME="width" VALUE="750">
<PARAM NAME="height" VALUE="550">
<PARAM NAME="archive" VALUE="ij.jar">
</APPLET>
</body>
</html>
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: ImageJ Applet problem running my code and opening images

Rasband, Wayne (NIH/NIMH) [E]
1064 posts
In reply to this post by thehobbit
On Nov 13, 2012, at 7:21 AM, thehobbit wrote:

> Hello everyone,
>
> I'm trying to run my JAVA code as an applet using also ImageJ API, but it
> doesn't work.

The ImageJ 1.47f daily build fixes a v1.46f regression that caused the ImageJ class (when running as an applet) to throw an exception. This caused code in ImageJApplet that opened images to be ignored.

-wayne

> I even have problem showing a simple image. Here is an example:
>
> public class ImageJApplet extends Applet {
>
> /** Starts ImageJ if it's not already running. */
>    public void init() {
>     ImageJ ij = IJ.getInstance();
>     if (ij==null || (ij!=null && !ij.isShowing()))
> new ImageJ(this);
>
>   ImagePlus imp = new
> ImagePlus("http://osasapere.it/wp-content/uploads/2011/06/dna_500.jpg");
>
> imp.show();
>
>    }
>
>    public void destroy() {
>     ImageJ ij = IJ.getInstance();
>     if (ij!=null) ij.quit();
>    }
>
> }
>
> The main istance of imageJ starts, but the image does not start at all.
> I have more code to run as an applet, like:
>
>            SelectionTool st = new SelectionTool();
>            st.run("");
>
> This code, for example, shows some JAVA button I made which run some imageJ
> API and so on, and it works when I run it in Eclipse, but fails to start as
> an applet.
>
> A "funny" thing I noticed is this: when I try to use this applet
> http://rsb.info.nih.gov/ij/applet2/ it does not show the images passed as
> parameters as it says, but starts only the main instance of imageJ.
> So, I don't know if the problem is my browser; I use Chrome.
>
> Can someone help me please?
>
> Thank you in advance
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/ImageJ-Applet-problem-running-my-code-and-opening-images-tp5000786.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html