Your button has been added to the frame. You'll notice a difference if you remove your frame.add()
line. The 'problem' lies with the following.
- You haven't specified a layout resulting in your frame using the default BorderLayout manager.
- You haven't specified a constraint in
frame.add()
. Because of this the component has been added to whatever the default position is for the layout which isBorderLayout.CENTER
. Components added to the center take up the much space as possible hence why your button is filling the entire frame.
Here's some tutorials on layout managers. You might want to have a read through these at some point.