File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Adding component in JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding component in JPanel" Watch "Adding component in JPanel" New topic

Adding component in JPanel

faisal hameed
Ranch Hand

Joined: Jan 19, 2009
Posts: 48
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.

Regards, M Faisal Hameed
PUCIT, Pakistan
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10768

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)

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: Adding component in JPanel
jQuery in Action, 3rd edition