If you want to create a class for each component, then you need to extend the super class.
say creating a button,,,
class SampleButton extends JButton..
And then you add this to container.
panel.add(new SampleButton());
To answer to the second part, if you want to add to the frame you need to get the contentpane and then add the components.
Hope this answers