Go to Post Wait, does this mean TV isn't real? I'm shocked and appalled. - s_forbes [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-29-2011, 07:54 PM
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Adding additional classes, in different files in Newbeans

Greetings,

Does anyone know how to add additional classes/files to a project created from an FRC iterative template? I add a new .java file to my project that includes a new public class, methods, etc. I can see the new file in Netbeans file navigator, but when I try to declare the new class in my main .java file, it doesn’t find it as the system is only looking the WPI library. How can I get the project to recognize additional classes and methods from different files?

Thanks in advance,

~TJ
Reply With Quote
  #2   Spotlight this post!  
Unread 01-29-2011, 08:12 PM
sjspry sjspry is offline
Registered User
FRC #1984
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Kansas
Posts: 125
sjspry has a spectacular aura aboutsjspry has a spectacular aura aboutsjspry has a spectacular aura about
Re: Adding additional classes, in different files in Newbeans

If you go to "New File" (Ctrl+N), it should add it in your project so it is seeable. Did you add it in a different package (different set of folders)? If so, hit Alt+Enter on the line where it gives you the error and it should say "Add import from ..."

That's the only problem I can see, if that's not it, perhaps a bit more description?
Reply With Quote
  #3   Spotlight this post!  
Unread 01-29-2011, 08:23 PM
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Re: Adding additional classes, in different files in Newbeans

Interesting....

Using alt-Enter I can add the file/class to the WPILib, but that is the only option. I'd prefer to add the files & classes to my project/src folder rather than modify the WPI library. Any thoughts?
Reply With Quote
  #4   Spotlight this post!  
Unread 01-29-2011, 08:51 PM
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: Adding additional classes, in different files in Newbeans

0. Open up the Projects Panel in Netbeans

1. Find the package where your "main" class is. This would be called the IterativeRobot or something you named it.

2. Right click on that package.

3. New>Class.
Reply With Quote
  #5   Spotlight this post!  
Unread 01-29-2011, 11:32 PM
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Re: Adding additional classes, in different files in Newbeans

Thanks for the insight.

We've found a bug in the Robot Drive WPI library class and we're trying to hack a fix until an update is released from WPI. I'm bringing the class local to make the change, but I'm having issues referencing the local version of the class.

When adding the class locally the only option that comes up is the default package and I'm having issues with using some of the method declarations within the class.

I'm continuing to play the option and really appreciate your insight.

I would like to temporarily make the change to the library, but it's read-only and I can't seem to change the attribute. Any chances you know how to modify the WPI library attributes?


Thanks again,

~TJ
Reply With Quote
  #6   Spotlight this post!  
Unread 01-30-2011, 10:43 AM
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Re: Adding additional classes, in different files in Newbeans

Still can't seem to find a way to instantiate a class from a file other that the main. All attempts fail. Perhaps someone provide a brief outline to illustrate a simple example of creating a class in file “A” and using it in file “B”?

Much appreciated.......

~TJ
Reply With Quote
  #7   Spotlight this post!  
Unread 01-30-2011, 10:46 AM
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Adding additional classes, in different files in Newbeans

Ok, go click on the "projects" tab and while it is open, take a screenshot of the screen and I will help you.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote
  #8   Spotlight this post!  
Unread 01-30-2011, 11:12 AM
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: Adding additional classes, in different files in Newbeans

Quote:
Originally Posted by tjakowenko View Post
Perhaps someone provide a brief outline to illustrate a simple example of creating a class in file “A” and using it in file “B”?
Quick, rudimentary example here. Two classes in same project and package. Main instantiates a new instance of the ManualDrive class, then invokes method driveMe() on it. This program will actually work btw

Code:
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.SimpleRobot;

public class Main extends SimpleRobot {

    ManualDrive drive = new ManualDrive();

    public void autonomous() {
    }

    public void operatorControl() {

        while (this.isOperatorControl()) {
            drive.driveMe();
        }
    }
}
Code:
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;

public class ManualDrive {

    Jaguar jag1 = new Jaguar(1);
    Jaguar jag2 = new Jaguar(2);
    RobotDrive drive = new RobotDrive(jag1, jag2);
    Joystick controllerOne = new Joystick(1);

    // constructor, needed to instantiate, can be empty
    public ManualDrive() {
    }

    public void driveMe() {
        drive.arcadeDrive(controllerOne);
    }
}
Reply With Quote
  #9   Spotlight this post!  
Unread 02-03-2011, 12:45 PM
tjakowenko tjakowenko is offline
Registered User
AKA: Tom Jakowenko
no team (Pirates of the Pythagorean)
Team Role: Mentor
 
Join Date: Oct 2009
Rookie Year: 2009
Location: Hartford, ct
Posts: 12
tjakowenko is an unknown quantity at this point
Re: Adding additional classes, in different files in Newbeans

Thanks you for your help. We have been able to change the WPI lib.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:37 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi