Can i add component to a jframe directly?

In jdk1.4.2, i can't add any component to a jframe. Instead, i have to use an object of Container getting from JFrame.getContentPane() to add components. But in jdk1.5.0 or higher version, i can add components to jframe directly by JFrame.add() method. Why is there such a different?
[291 byte] By [youhaodiyia] at [2007-11-27 8:50:37]
# 1

The difference is basically in the implementation of the add method. It is mostly that in JDK 5.0 the add( ) was just rewritten to delegate its addition of components to the content pane. ie.

public void add(Component c) {

//it simply calls

getContentPane().add( c );

}

Im not exactly sure of this, however, you can check the source code in your jdk directory to see if this is what is done in JFrame

ICE

icewalker2ga at 2007-7-12 21:02:07 > top of Java-index,Desktop,Core GUI APIs...
# 2

> Why is there such a different?

Probably because the designers got tired of people asking questions like this.

I can use panel.add(...);

Why do I need to use frame.getContentPane().add(...)?

Don't worry about insignificant issues like this. The API is always evolving.

camickra at 2007-7-12 21:02:07 > top of Java-index,Desktop,Core GUI APIs...