title: Java: Difficulty with Swing
body: <p>I'm trying to modify a GUI. It is hosting a GLCanvas displaying JOGL content.</p>
  
  <p>Here is the code to set it up:</p>
  
  <pre><code>private void setupWindow() {
      this.frame = new JFrame(WINDOW_TITLE);
      frame.setSize(width, height);
      frame.setVisible(true);
  
      frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
              System.exit(0);
          }
      });
  
      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("File");
      menuBar.add(menu);
      JMenuItem exitItem = new JMenuItem("Exit");
      exitItem.addActionListener(listener);
      menu.add(exitItem);
      frame.setJMenuBar(menuBar);
  }
  </code></pre>
  
  <p>Currently, the canvas takes up the entire space in the window, aside from the menu bar. I'd like to make space for other controls in the window, like buttons and list boxes. How can I do it?</p>
  
  <p>I tried inserting the following, but it didn't work:</p>
  
  <pre><code>private void setupWindow() {
      this.frame = new JFrame(WINDOW_TITLE);
      frame.setSize(width, height);
  
      // ** inserted the following:
      JPanel canvasPanel = new JPanel(new BorderLayout());
      canvasPanel.add(canvas);
      canvasPanel.setSize(30, 40);
      canvasPanel.setVisible(true);
      // **
  
      frame.add(canvasPanel);
      frame.setVisible(true);
  
      frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
              System.exit(0);
          }
      });
  
      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("File");
      menuBar.add(menu);
      JMenuItem exitItem = new JMenuItem("Exit");
      exitItem.addActionListener(listener);
      menu.add(exitItem);
      frame.setJMenuBar(menuBar);
  }
  </code></pre>
  
  <p>This doesn't modify the appearance of the window at all.</p>
  
  <p>What should I be doing here? I'm not too familiar with Java GUIs.</p>
  
  <p><strong>Update</strong>: Changing the constructor's argument from <code>BorderLayout</code> to <code>FlowLayout</code> causes the GLCanvas to disappear.</p>