• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Container?

 
Ghazala Islam
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As in AWT ,when we extends Frame,we can directly
add components e.g Panel on Frame like add(p1).
but why when we use Swing and Extends Jframe we cannot directly add component to Jframe,first we have to create Container c = getContentPane()
and then add panel to it?
 
Rob Ross
Bartender
Posts: 2205
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Swing containers are a little more complex. There's a single child of a JFrame called a JRootPane. This pane contains the content pane, the menu bar (if there is one), and a layered pane and glass pane.
You add your user-components to the content pane. The other panes are used for different things. For example, drawing into the glass pane will draw your component on top of everything else.
There's a good swing tutorial on using JRootPane. You should look up the API docs for JRootPane and read up on it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic