JFrames (and your subclasses of them) have a content pane,
which is where you add components, which are positioned by the
layout manager when you call
There are no special problems with this,
so if you just interested interested in getting your program
running, stop reading now. What follows is information
that will help you understand variations you'll see in other programs.
You will see all of these approaches used. They are all reasonable. Choose the one which makes you most comfortable.
getContentPanefor every reference.
this.getContentPane().add(...); this.getContentPane().add(...); . . .
Container content = this.getContentPane(); content.add(...); content.add(...); . . .
JPanel content = new JPanel(); content.add(...); content.add(...); . . . this.setContentPane(content);
When you create a JFrame, it comes with a content pane which has already been created. [TODO: Discuss small advantages of using a JPanel as opposed to Container].
[TODO: Discuss this "new" Java 5 feature mistake.]