This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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: 11021
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