Quote:
Originally Posted by ksanger
Java Help;
We are copying examples out of WPI Robotics Library User’s Guide.pdf which state that we may define a new Joystick(int USBPort#, int #ofAxis, int #ofButtons) but when we do so Netbeans gives us an error stating that
"Joystick(int,int,int) has protected access in edu.wpi.first.pwilibj.Joystick ..."
Alt Ent shows hints which repeats the same message.
First what does this mean, and second how do we fix it. Our team wants to use a gamepad... And we were hoping to be able to determine what the gamepad response is tonight.
|
protected means you can only access it if your class derives from the class it is defined in,
Quote:
|
We did find Joystic.java and see that Joystick( int port, int numAxisTypes, int numButtonTypes){} is defined as protected. Can we just change this to public? Is this a bug? (note changing it to public and saving the file hasn't worked yet.) (note again, quite Netbeans, restarted, and now have no error message). This is extremely frustrating as the documentation didn't work the first time and I don't know if what I did to fix it is correct, nor if it broke something else?
|
When you change the library you have to rebuild it not just save it. When you first start netbeans it does a full build. You can change anything you want, but be careful:
When updates come out your changes are over-written.
Chances are the code that is there is better than what you will replace it with. That isn't a poke at you, and there are bugs here and there, but in general the WPI guys do a good job.
I changed a few things here and there, including making things public. But be careful and prepared to maintain it yourself.
Quote:
New questions;
1) If we change a library function should we create a new copy of it and put it in our current project instead of using the library?
|
I would usually so that they aren't over-written with updates.
Quote:
|
2) Why didn't Netbeans see the library change until we restarted it?
|
Answered above.
Quote:
|
3) How do we determine if our change doesn't cause additional problems and break something else?
|
That is indeed the question!
If you aren't comfortable that you are either fixing a definte bug, or creating a new functionality, you should leave it alone. You can always extend the Joystick or HID classes and not worry that you've caused an unforeseen side effect.
(BTW when you do find actual bugs post them to Source Forge so that they can get fixed for everyone)
Good Luck & happy Java-ing