Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding component in JPanel

 
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
Saloon Keeper
Posts: 11027
12
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic