Link to home
Start Free TrialLog in
Avatar of meow00
meow00

asked on

getContentPane() ...

Hi Experts,

    I am reading the JFrame in the Sun java tutorial. I saw JFrame has the following function :
   
    getContentPane() :  Returns the contentPane object for this frame.

    I don't know what "contentPane" is ... and I can not find the "contentPane" class or container it in the tutorial ....... could anyone please give me some directions ? Thanks a lot !

 meow.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

contentpane is the container that you add components to.
it is a Container.
ie. you don't add components to the frame, you instead add them to the content pane.

eg.

Container pane = frame.getContentPane();
pane.setLayout(new FlowLayout());
pane.add(new JLabel("X"));
Avatar of meow00
meow00

ASKER

Thanks .... so is it true that : in the

 "pane.setLayout(new FlowLayout());
  pane.add(new JLabel("X")); "

 we still use JFrame method setLayout() and add(), even though they are invoked by a pane rather than a frame ?

  thanks !

SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium 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
SOLUTION
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
ASKER CERTIFIED SOLUTION
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
Thank you