Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!