Results 1 to 5 of 5
  1. #1
    frog is offline Member
    Join Date
    Jan 2015
    Posts
    2
    Rep Power
    0

    Default How Link netbeans to netlogo

    I want to connect netbeans to netlogo. I have a class: NetLogoConnection I want to call the class when I click on OK btn in my GUI. The codes are as following:


    XML Code:
    import org.nlogo.app.App;
    public class NetLogoConnection {
      public static void main(String[] argv) {
        App.main(argv);
        try {
          java.awt.EventQueue.invokeAndWait(
        new Runnable() {
          public void run() {
            try {
              App.app().open("C:/Users/fmar825/Desktop/fire.nlogo");
            }
            catch(java.io.IOException ex) {
              ex.printStackTrace();
            }}});
         // App.app().command("set density 62");
         // App.app().command("random-seed 0");
         // App.app().command("setup");
          //App.app().command("repeat 50 [ go ]");
          //System.out.println(
    //App.app().report("burned-trees"));
        }
        catch(Exception ex) {
          ex.printStackTrace();
        }
      }
    }
    And the code for calling the class with JButton is as following :

    XML Code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
           NetLogoConnection.main(argv);
          
        }
    The error Message is a s following:


    XML Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.nlogo.app.App$.moreTokens$1(App.scala:163)
    at org.nlogo.app.App$.processCommandLineArguments(App.scala:164)
    at org.nlogo.app.App$.main(App.scala:82)
    at org.nlogo.app.App.main(App.scala)
    at NetLogoConnection.main(NetLogoConnection.java:4)
    at User.jButton1ActionPerformed(User.java:989)
    at User.access$1600(User.java:31)
    at User$19.actionPerformed(User.java:601)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6525)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6290)
    at java.awt.Container.processEvent(Container.java:2234)
    at java.awt.Component.dispatchEventImpl(Component.java:4881)
    at java.awt.Container.dispatchEventImpl(Container.java:2292)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
    at java.awt.Container.dispatchEventImpl(Container.java:2278)
    at java.awt.Window.dispatchEventImpl(Window.java:2739)
    at java.awt.Component.dispatchEvent(Component.java:4703)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:719)
    at java.awt.EventQueue$4.run(EventQueue.java:717)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    Last edited by frog; 03-09-2015 at 06:34 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: How Link netbeans to netlogo

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.nlogo.app.App$.moreTokens$1(App.scala:163)
    at org.nlogo.app.App$.processCommandLineArguments(App .scala:164)
    at org.nlogo.app.App$.main(App.scala:82)
    at org.nlogo.app.App.main(App.scala)
    at NetLogoConnection.main(NetLogoConnection.java:4)
    There was a variable with a null value when line 163 was executed. That code was called from line 4 in NetLogoConnection. Look at line 4, find the variable with the null value and then backtrack in the code to see why there isn't a valid value there instead of a null.
    Last edited by Norm; 03-09-2015 at 03:43 AM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    27

    Default Re: How Link netbeans to netlogo

    Quote Originally Posted by frog View Post
    XML Code:
            }}});
    Code Conventions for the Java Programming Language: Contents

    Yes, that page is not maintained but those are still the conventions followed by almost all Java coders.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    frog is offline Member
    Join Date
    Jan 2015
    Posts
    2
    Rep Power
    0

    Default Re: How Link netbeans to netlogo

    Thanks for your prompt reply. how i can find variable with null value. do you mean that i have to change app.main(argv) to App.main(null).

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: How Link netbeans to netlogo

    how i can find variable with null value
    Use a print statement to print the values of argv.
    What is the value of argv when that code is executed?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 16
    Last Post: 07-02-2014, 02:02 PM
  2. Link list help
    By Poles_Apart in forum New To Java
    Replies: 5
    Last Post: 02-28-2012, 02:18 PM
  3. Someone posted a link here
    By coltragon in forum New To Java
    Replies: 3
    Last Post: 01-07-2010, 09:37 PM
  4. Link for 64 bit JDK.
    By aparna in forum New To Java
    Replies: 0
    Last Post: 03-19-2008, 03:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •