• Post Reply Bookmark Topic Watch Topic
  • New Topic

Awt and Swing  RSS feed

 
gurpreetsingh hora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone suggest me what's the differnce B/W

setLayout() in AWT

ann Obj.setLayout()=getContentpane(); in Swing
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might get a better response in the forum devoted to Swing/AWT. I'm going to move this thread over there.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never seen this in Swing
Obj.setLayout()=getContentpane();

setLayout is a setter, requiring a LayoutManager as its argument
getContentPane is a getter that returns an awt.Container
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A LayoutManager object helps a Container object position and size its Component objects.

Each Container has a default LayoutManager object. You can change the default LayoutManager object to a LayoutManager object of a class of your own choosing with a call to setLayout().

The method: setLayout() takes a LayoutManager object as its parameter or takes null for a manual layout in which case you have to position and size the Component objects yourself.

The statement:

f.setLayout(aLayoutManager);

sets the LayoutManager object of a JFrame, assuming that f is an instance of JFrame. The statement:

f.getContentPane().setLayout(anotherLayoutManager);

sets the LayoutManager object of the content pane of the JFrame.

Sometimes when you call a method of a Window, it is implied that you're really working on the content pane. Maybe, somebody can help me to understand this.

Kaydell
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!