Quantcast

Can't get JPanel to open

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Can't get JPanel to open

Christopher Coulon-2
I am trying to get my JPanel to display in my Netbeans project; I am using 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 code, which creates an instance of ImageJ, but does not show the JPanel.  I tried the code "IJ.runPlugIn(clazz.getName(), "”);” and " RoA_ ra = new RoA_(); ra.setVisible(true);”, but nothing works.  How do I get the JPanel 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 = RoA_.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
String pluginsDir = 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 = IJ.openImage("http://imagej.net/images/clown.jpg");
// image.show();

// run the plugin
IJ.runPlugIn(clazz.getName(), "");
                RoA_ ra = new RoA_();
                ra.setVisible(true);
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can't get JPanel to open

Emilian Bold-2
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 <[hidden email]> wrote:
I am trying to get my JPanel to display in my Netbeans project; I am using 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 code, which creates an instance of ImageJ, but does not show the JPanel.  I tried the code "IJ.runPlugIn(clazz.getName(), "”);” and " RoA_ ra = new RoA_(); ra.setVisible(true);”, but nothing works.  How do I get the JPanel 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 = RoA_.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
String pluginsDir = 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 = IJ.openImage("http://imagej.net/images/clown.jpg");
// image.show();

// run the plugin
IJ.runPlugIn(clazz.getName(), "");
                RoA_ ra = new RoA_();
                ra.setVisible(true);
}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can't get JPanel to open

Enrico Scantamburlo
In reply to this post by Christopher Coulon-2
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" <[hidden email]> wrote:
I am trying to get my JPanel to display in my Netbeans project; I am using 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 code, which creates an instance of ImageJ, but does not show the JPanel.  I tried the code "IJ.runPlugIn(clazz.getName(), "”);” and " RoA_ ra = new RoA_(); ra.setVisible(true);”, but nothing works.  How do I get the JPanel 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 = RoA_.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
String pluginsDir = 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 = IJ.openImage("http://imagej.net/images/clown.jpg");
// image.show();

// run the plugin
IJ.runPlugIn(clazz.getName(), "");
                RoA_ ra = new RoA_();
                ra.setVisible(true);
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Can't get JPanel to open

Peter Hansson-2
Christian,   are you really creating a Netbeans Platform application?    Aren't you just creating a normal Java application?   ... and you just happen to be using NetBeans IDE for your development?

I have a feeling that you have hit the wrong mailing list with this question. Ask youself:  Is the fact that you are using NetBeans IDE relevant for the question you are asking?  If not, your question is probably better suited for another mailing list or perhaps SO.



On Thu, Mar 16, 2017 at 1:59 PM, Enrico Scantamburlo <[hidden email]> wrote:
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" <[hidden email]> wrote:
I am trying to get my JPanel to display in my Netbeans project; I am using 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 code, which creates an instance of ImageJ, but does not show the JPanel.  I tried the code "IJ.runPlugIn(clazz.getName(), "”);” and " RoA_ ra = new RoA_(); ra.setVisible(true);”, but nothing works.  How do I get the JPanel 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 = RoA_.class;
String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
String pluginsDir = 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 = IJ.openImage("http://imagej.net/images/clown.jpg");
// image.show();

// run the plugin
IJ.runPlugIn(clazz.getName(), "");
                RoA_ ra = new RoA_();
                ra.setVisible(true);
}

Loading...