Re: Can't get JPanel to open

Enrico Scantamburlo <[email protected]> Thu, 16 Mar 2017 13:59:10 +0100
Newsgroups gmane.comp.java.netbeans.devel
Message-ID <CAJdy_m-+5_7vN7UhaOLYReC455gWHmu6a1v5J2B6ZqV7ZvCCiw@mail.gmail.com>
--001a11426a6291c2e7054ad8a089
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

there is no public static void main method in an netbeans rcp application.
You should create a topcomponent and add the psnel to it.

in case of a standalone application you must create a jframe, add the
jpanel to it and then make the jframe visible.

On 15 Mar 2017 19:28, "Christopher Coulon" <[email protected]>
wrote:

> I am trying to get my JPanel to display in my Netbeans project; I am usin=
g
> the Maven git hub Process_Pixels, and I can run that class with the image
> and the instance of ImageJ, but I cannot find any way to display my GUI
> (JPanel).  I created a class from my RoA_.java code, and I tried this cod=
e,
> which creates an instance of ImageJ, but does not show the JPanel.  I tri=
ed
> the code "IJ.runPlugIn(clazz.getName(), "=E2=80=9D);=E2=80=9D and " RoA_ =
ra =3D new RoA_();
> ra.setVisible(true);=E2=80=9D, but nothing works.  How do I get the JPane=
l to show
> up?
>
> public static void main(String[] args) {
> // set the plugins.dir property to make the plugin appear in the Plugins
> menu
> Class<?> clazz =3D RoA_.class;
> String url =3D clazz.getResource("/" + clazz.getName().replace('.', '/') =
+
> ".class").toString();
> String pluginsDir =3D url.substring("file:".length(), url.length() -
> clazz.getName().length() - ".class".length());
> System.setProperty("plugins.dir", pluginsDir);
>
> // start ImageJ
> new ImageJ();
>
> // open the Clown sample
> // ImagePlus image =3D IJ.openImage("http://imagej.net/images/clown.jpg")=
;
> // image.show();
>
> // run the plugin
> IJ.runPlugIn(clazz.getName(), "");
>                 RoA_ ra =3D new RoA_();
>                 ra.setVisible(true);
> }
>
>

--001a11426a6291c2e7054ad8a089
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">there is no public static void main method in an netbeans=
 rcp application. You should create a topcomponent and add the psnel to it.=
=C2=A0<div dir=3D"auto"><br></div><div dir=3D"auto">in case of a standalone=
 application you must create a jframe, add the jpanel to it and then make t=
he jframe visible.</div></div><div class=3D"gmail_extra"><br><div class=3D"=
gmail_quote">On 15 Mar 2017 19:28, &quot;Christopher Coulon&quot; &lt;<a hr=
ef=3D"mailto:[email protected]" target=3D"_blank">christopher.co=
[email protected]</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"=
gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-=
left:1ex"><div style=3D"word-wrap:break-word">I am trying to get my JPanel =
to display in my Netbeans project; I am using the Maven git hub Process_Pix=
els, and I can run that class with the image and the instance of ImageJ, bu=
t I cannot find any way to display my GUI (JPanel).=C2=A0 I created a class=
 from my RoA_.java code, and I tried this code, which creates an instance o=
f ImageJ, but does not show the JPanel.=C2=A0 I tried the code &quot;IJ.run=
PlugIn(clazz.getName(), &quot;=E2=80=9D);=E2=80=9D and &quot; RoA_ ra =3D n=
ew RoA_(); ra.setVisible(true);=E2=80=9D, but nothing works.=C2=A0 How do I=
 get the JPanel to show up?<div><br></div><blockquote style=3D"margin:0px 0=
px 0px 40px;border:none;padding:0px"><div><div><span class=3D"m_-4273076654=
06810701Apple-tab-span" style=3D"white-space:pre-wrap">	</span>public stati=
c void main(String[] args) {</div><div><span class=3D"m_-427307665406810701=
Apple-tab-span" style=3D"white-space:pre-wrap">		</span>// set the plugins.=
dir property to make the plugin appear in the Plugins menu</div><div><span =
class=3D"m_-427307665406810701Apple-tab-span" style=3D"white-space:pre-wrap=
">		</span>Class&lt;?&gt; clazz =3D RoA_.class;</div><div><span class=3D"m_=
-427307665406810701Apple-tab-span" style=3D"white-space:pre-wrap">		</span>=
String url =3D clazz.getResource(&quot;/&quot; + clazz.getName().replace(&#=
39;.&#39;, &#39;/&#39;) + &quot;.class&quot;).toString();</div><div><span c=
lass=3D"m_-427307665406810701Apple-tab-span" style=3D"white-space:pre-wrap"=
>		</span>String pluginsDir =3D url.substring(&quot;file:&quot;.length()<wb=
r>, url.length() - clazz.getName().length() - &quot;.class&quot;.length());=
</div><div><span class=3D"m_-427307665406810701Apple-tab-span" style=3D"whi=
te-space:pre-wrap">		</span>System.setProperty(&quot;plugins.<wbr>dir&quot;=
, pluginsDir);</div><div><br></div><div><span class=3D"m_-42730766540681070=
1Apple-tab-span" style=3D"white-space:pre-wrap">		</span>// start ImageJ</d=
iv><div><span class=3D"m_-427307665406810701Apple-tab-span" style=3D"white-=
space:pre-wrap">		</span>new ImageJ();</div><div><br></div><div><span class=
=3D"m_-427307665406810701Apple-tab-span" style=3D"white-space:pre-wrap">		<=
/span>// open the Clown sample</div><div>//<span class=3D"m_-42730766540681=
0701Apple-tab-span" style=3D"white-space:pre-wrap">		</span>ImagePlus image=
 =3D IJ.openImage(&quot;<a href=3D"http://imagej.net/images/clown.jpg" targ=
et=3D"_blank">http://imagej.<wbr>net/images/clown.jpg</a>&quot;);</div><div=
>//<span class=3D"m_-427307665406810701Apple-tab-span" style=3D"white-space=
:pre-wrap">		</span>image.show();</div><div><br></div><div><span class=3D"m=
_-427307665406810701Apple-tab-span" style=3D"white-space:pre-wrap">		</span=
>// run the plugin</div><div><span class=3D"m_-427307665406810701Apple-tab-=
span" style=3D"white-space:pre-wrap">		</span>IJ.runPlugIn(clazz.getName(),=
 &quot;&quot;);</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 RoA_ ra =3D new RoA_();</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 ra.setVisible(true);</div><div><span class=3D"m_-4273=
07665406810701Apple-tab-span" style=3D"white-space:pre-wrap">	</span>}</div=
></div></blockquote></div></blockquote></div></div>

--001a11426a6291c2e7054ad8a089--