Link to home
Start Free TrialLog in
Avatar of InteractiveMind
InteractiveMindFlag for United Kingdom of Great Britain and Northern Ireland

asked on

setPreferredSize( Dimension ) ?

Hi,

in what class is the setPreferredSize(Dimension) method declared (furthest up the hierachy)?

Because, I traced it down to: javax.swing.JComponent. However, that method has the following:

    public void setPreferredSize( Dimension dim )
    {
        super.setPreferredSize( dim );
    }

However, the class that JComponent extends: Component, doesn't seem to have a declaration for setPreferredSize() !?

Where is it?

Thanks,
Rob.
ASKER CERTIFIED SOLUTION
Avatar of aozarov
aozarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aozarov
aozarov

But I think JComponent does override it:
see (from JComponent class):
public void setPreferredSize(Dimension preferredSize) {
      Dimension old = this.preferredSize;
        this.preferredSize = preferredSize;
        firePropertyChange("preferredSize", old, preferredSize);
    }
So, I guess maybe we are using different JDK versions and in your case the delegation is to the Component class.
Which version of Swing are using?
I checked back and even with the Swing that comes with JDK 1.3 JComponent provides the implementation and doesn't call super.setPreferredSize
Oh, and Component#setPreferredSize is only since 1.5.
Avatar of InteractiveMind

ASKER

Thanks very much both..

lol -- I have no idea how, but, I just checked the Component.java class again, and I found the declaration for setPreferredSize(Dimension preferredSize) !! :o\

(Yeah, I'm using 1.5).

How strange; I have no idea how I missed it. lol.

Sorry!!
Point split. :-)

Regards;
Rob.
:-)
:-)