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

Adding component in JPanel  RSS feed

 
faisal hameed
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class Ball extends JPanel.I am adding object of ball class in JPanel having null Layout.But it is not appear on JPanel.How can i add object of ball class in JPanel having layout null.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After adding the ball to the frame, you have forgotten to set the bounds for the ball.

Using a null layout is always a bad idea. Why do you want to do that?
The frame's content pane defaults to BorderLayout If you do not set the layout to null, your Ball panel will occupy the whole frame (default: BorderLayout.CENTER)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!