|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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? |
|
#3
|
|||
|
|||
|
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? |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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.
|
|
#8
|
|||
|
|||
|
Re: Adding additional classes, in different files in Newbeans
Quote:
![]() 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);
}
}
|
|
#9
|
|||
|
|||
|
Re: Adding additional classes, in different files in Newbeans
Thanks you for your help. We have been able to change the WPI lib.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|