Q:

java swing multiple jpanels

Basically all I want to do is draw two rows of buttons for a lights out game (homework), but I don't know how to make both panels show up. I've pretty much almost no graphics before, and I don't really understand anything I'm doing.
The panels them selves work, but it just shows whichever I add second (I assume it's overwriting the previous panel)
public static void main(String[] args) {
    String nButtonsString = JOptionPane.showInputDialog("How many buttons would you like?");
    int nButtons = Integer.parseInt(nButtonsString);
    JFrame myFrame = new JFrame();

    myFrame.setTitle("Linear Lights Out Game.");
    myFrame.setSize(FRAME_SIZE);    

    JPanel control_buttons = new Linear_Controls();
    myFrame.add(control_buttons);

    JPanel lights = new LinearLightsPanel(nButtons);
    myFrame.add(lights);

    myFrame.pack();
    myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    myFrame.setVisible(true);

A:

myFrame.add(control_buttons);
myFrame.add(lights);

By default a JFrame uses a BorderLayout. Also, by default components get added to the CENTER of the BorderLayout. However the CENTER can only contain a single component so only the last component added is displayed. Try:
myFrame.add(control_buttons, BorderLayout.NORTH);

Now the two components should show up.
Read the section from the Swing tutorial on Using Layout Managers for more information and examples. Also take a look at the Trail/Table of Contents link to see other useful topics for basic Swing usage.

