but when i run it i get this:
You get an empty screen because you add the components to the frame after the frame is visible.
- As has already been suggested you need to use an appropriate layout manager. FlowLayout is the easiest to start with.
- invoke
setVisible(true)
AFTER adding the components to the frame.
So the code should be more like:
panel.add(...);
panel.add(...);
add(panel);
pack();
setVisible(true);