Well, if you do want to extend from that java.awt.Component class you
have to play it by the rules: everything that's mentioned in the API docs
can be used and manipulated but you wanted to touch some of that
object's internals which is, rightly so, not allowed.
I found this java swing validation package you can build online. I followed all the steps creating the classes and everything compiles. However, when I make the call to the constructor I still recieve
"parent is not public in java.awt.Component; cannot be accessed from outside package.." I understand from earlier in this post that I'm trying to access something I'm not aloud to do, but I'm a little lost on how I could go about achieving what I want.
Many of you might of came across this tutorial...
Do I personally have to create my own package and import it into my program I would like to use it in? If so, how would I achieve this?
Your Component doesn't know who it's containing parent is. Any
container will set this value. Look at the Component API docs: there
is no way to set the parent (using a method).
You know where the source code is already; have a look at the Container addImpl method: it manipulates the parent member variable
directly. It is allowed to do so because a Container is a Component
and they both reside in the same package.