Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]Inherit Question[/b]

Status
Not open for further replies.

naruto20

Programmer
Jan 22, 2005
2
US
Hey!

My question is can the Properties of a Subclass that is inside of a SuperClass be CHANGE by another Subclass?

I have a class that is an extends of JFrame which is the Superclass and another
one that is a extends of a JPanel which is the Subclass that is inside of the Superclass. The other Subclass is one that wants to Change the setLocation of the JPanel subclass, but it doesn't do it. i can see the value of the properties but i can't change it.

If you can help me PLIZZ do : ) i been stock on this for like 2 days.
 
I'm not exactly clear on what you're trying to ask. Are you trying to say that both your subclass of JPanel and your subclass of JFrame have a setLocation method and that you are trying to transfer one to the other?

From what it looks like, setLocation is an inherited method from Container, which means you should be able to transfer the values from one to the other. You have to use getLocation to get the Point object that contains the coords.

So, assuming that you are using this inherited setLocation, all you'd really need to do is:

Code:
Point pt = myPanel.getLocation();
double xCoord = pt.getX();
double yCoord = pt.getY();

myFrame.setLocation(xCoord, yCoord);
Is that what you wanted?

Nick Ruiz
Webmaster, DBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top