NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Can't get JPanel to open

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers
View previous topic :: View next topic  
Author Message
Christopher Coulon
Posted via mailing list.





PostPosted: Wed Mar 15, 2017 6:29 pm    Post subject: Can't get JPanel to open Reply with quote

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?
Quote:
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);
}

Back to top
emi



Joined: 14 Aug 2009
Posts: 238

PostPosted: Thu Mar 16, 2017 6:23 am    Post subject: Can't get JPanel to open Reply with quote

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 <address-removed ([email]address-removed[/email])> wrote:
Quote:
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?

Quote:
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);
}


Back to top
Enrico Scantamburlo
Posted via mailing list.





PostPosted: Thu Mar 16, 2017 1:00 pm    Post subject: Can't get JPanel to open Reply with quote

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" <address-removed ([email]address-removed[/email])> wrote:
Quote:
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?

Quote:
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);
}


Back to top
Peter Hansson
Posted via mailing list.





PostPosted: Thu Mar 16, 2017 1:39 pm    Post subject: Can't get JPanel to open Reply with quote

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 <address-removed ([email]address-removed[/email])> wrote:
Quote:
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" <address-removed ([email]address-removed[/email])> wrote:
Quote:
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?

Quote:
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);
}






Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo