tags:

views:

234

answers:

3

What is mean 'Container a=new getContentPane()" ?

A: 

I don't think this is valid code. According to this Sun tutorial, the new keyword requires a constructor call as its argument, i.e. something like Rectangle(); a class name followed by a list of arguments (optional). Your code doesn't have this, instead it has a regular method call.

unwind
Technically, nothing prevents you from having a class named "getContentPane"
Michael Borgwardt
A: 

A variable named 'a' of type Container is declared and assigned a new Object of class getContentPane.

Since 'getContentPane' violates the Java naming conventions for classes (which ascribe a capitalized first letter) and is also a prominent method name in Swing frames, it's probably a mistake and results in a compiler error.

Try removing the "new" to call the method rather than constructing an object.

Michael Borgwardt
+2  A: 

Container a=new getContentPane()" wouldn't compile...

getContentPane() is a method of javax.swing.RootPaneContainer.

Container a = getContentPane() would get the contentPane of the component.

This part of the Swing tutorial talks about panes a bit.

TofuBeer