Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

please help!!  RSS feed

 
asheet anand
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell me what are "panes" in refrence to swings
particularly "content pane".
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A pane is a type of container for other components. There are several swing containers that have a content pane as their only child. In order to add components to that container, you have to get a reference to its content pane and add components to that. JApplet and JFrame are two examples of this. This is how you would go about it:
<PRE>
public class myApplication extends JFrame{
public myApplication(){
JButton theButton = new JButton("Press Me!");
Container c = getContentPane();
c.add(theButton);
pack();
}
public static void main(String args[]){
new myApplication.show();
}
}
</PRE>
Of course you would probably want to change the layout manager, add more components, and handle events (at least window closing!) But hopefully it gives you an idea of how to use the content pane.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!