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.
LVL 25
InteractiveMindAsked:
Who is Participating?
 
aozarovCommented:
it is declared in the Component class.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
aozarovCommented:
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);
    }
0
 
aozarovCommented:
So, I guess maybe we are using different JDK versions and in your case the delegation is to the Component class.
0
 
aozarovCommented:
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
0
 
aozarovCommented:
Oh, and Component#setPreferredSize is only since 1.5.
0
 
InteractiveMindAuthor Commented:
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.
0
 
CEHJCommented:
:-)
0
 
aozarovCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.