Re: Can't get JPanel to open
Emilian Bold <[email protected]> Thu, 16 Mar 2017 08:21:41 +0200
| Newsgroups | gmane.comp.java.netbeans.devel |
|---|---|
| Message-ID | <CAL6R17B8YxysZjCpL-94dKLvnAGwr0GpKYV+o+GX=X4NU7ttKA@mail.gmail.com> |
--94eb2c0e5d90782f21054ad31549 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I assume you are trying to do this with a NetBeans Platform app or module, no? Besides the missing UI do you see any errors? You might want to take a look at the way the NetBeans Module System works. Perhaps ImageJ accepts a ClassLoader argument? You can get the main ClassLoader from Lookup.getDefault() http://wiki.netbeans.org/ClassloaderTrick --emi On Wed, Mar 15, 2017 at 8:28 PM, 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); > } > > --94eb2c0e5d90782f21054ad31549 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">I assume you are trying to do this with a NetBeans Platfor= m app or module, no? Besides the missing UI do you see any errors?<div><br>= </div><div>You might want to take a look at the way the NetBeans Module Sys= tem works.</div><div><br></div><div>Perhaps ImageJ accepts a ClassLoader ar= gument? You can get the main ClassLoader from Lookup.getDefault()=C2=A0<a h= ref=3D"http://wiki.netbeans.org/ClassloaderTrick">http://wiki.netbeans.org/= ClassloaderTrick</a></div><div><br></div></div><div class=3D"gmail_extra"><= br clear=3D"all"><div><div class=3D"gmail_signature" data-smartmail=3D"gmai= l_signature"><div dir=3D"ltr"><div><br></div><div>--emi<br></div></div></di= v></div> <br><div class=3D"gmail_quote">On Wed, Mar 15, 2017 at 8:28 PM, Christopher= Coulon <span dir=3D"ltr"><<a href=3D"mailto:[email protected]= m" target=3D"_blank">[email protected]</a>></span> wrote:<br>= <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word">I am try= ing to get my JPanel to display in my Netbeans project; I am using the Mave= n git hub Process_Pixels, and I can run that class with the image and the i= nstance of ImageJ, but 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 of ImageJ, but does not show the JPanel.=C2=A0 I tried = 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.=C2=A0 How do I get the JPanel to show up?<div><br></div><blockquote = style=3D"margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><span c= lass=3D"m_-2452230949949566499Apple-tab-span" style=3D"white-space:pre-wrap= "> </span>public static void main(String[] args) {</div><div><span class=3D= "m_-2452230949949566499Apple-tab-span" style=3D"white-space:pre-wrap"> </s= pan>// set the plugins.dir property to make the plugin appear in the Plugin= s menu</div><div><span class=3D"m_-2452230949949566499Apple-tab-span" style= =3D"white-space:pre-wrap"> </span>Class<?> clazz =3D RoA_.class;</di= v><div><span class=3D"m_-2452230949949566499Apple-tab-span" style=3D"white-= space:pre-wrap"> </span>String url =3D clazz.getResource("/" + c= lazz.getName().replace('.', '/') + ".class").toSt= ring();</div><div><span class=3D"m_-2452230949949566499Apple-tab-span" styl= e=3D"white-space:pre-wrap"> </span>String pluginsDir =3D url.substring(&qu= ot;file:".length()<wbr>, url.length() - clazz.getName().length() - &qu= ot;.class".length());</div><div><span class=3D"m_-2452230949949566499A= pple-tab-span" style=3D"white-space:pre-wrap"> </span>System.setProperty(&= quot;plugins.<wbr>dir", pluginsDir);</div><div><br></div><div><span cl= ass=3D"m_-2452230949949566499Apple-tab-span" style=3D"white-space:pre-wrap"= > </span>// start ImageJ</div><div><span class=3D"m_-2452230949949566499Ap= ple-tab-span" style=3D"white-space:pre-wrap"> </span>new ImageJ();</div><d= iv><br></div><div><span class=3D"m_-2452230949949566499Apple-tab-span" styl= e=3D"white-space:pre-wrap"> </span>// open the Clown sample</div><div>//<s= pan class=3D"m_-2452230949949566499Apple-tab-span" style=3D"white-space:pre= -wrap"> </span>ImagePlus image =3D IJ.openImage("<a href=3D"http://im= agej.net/images/clown.jpg" target=3D"_blank">http://imagej.<wbr>net/images/= clown.jpg</a>");</div><div>//<span class=3D"m_-2452230949949566499Appl= e-tab-span" style=3D"white-space:pre-wrap"> </span>image.show();</div><div= ><br></div><div><span class=3D"m_-2452230949949566499Apple-tab-span" style= =3D"white-space:pre-wrap"> </span>// run the plugin</div><div><span class= =3D"m_-2452230949949566499Apple-tab-span" style=3D"white-space:pre-wrap"> = </span>IJ.runPlugIn(clazz.getName(), "");</div><div>=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 RoA_ ra =3D new RoA_();</div><di= v>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ra.setVisible(tru= e);</div><div><span class=3D"m_-2452230949949566499Apple-tab-span" style=3D= "white-space:pre-wrap"> </span>}</div></div></blockquote></div></blockquote= ></div><br></div> --94eb2c0e5d90782f21054ad31549--