A JComponent doesn't use a Layout Manager so when you add the button it doesn't display.
Try using a FlowLayout
on your component.
Also, don't use setBounds() for your frame. You should pack()
and then use setLocationByPlatform(true)
, so the frame is displayed at its preferred size.
You would need to implement getPreferredSize()
for your component so this works.