title: How to make a JFrame scrollable in Java?
body: <p>I have this code in which I am trying to fit a scrollable Panel (JPanel) but I don't get it. Here is my code:</p>
  
  <pre><code>public class Sniffer_GUI extends JFrame {
  Canvas c = new Canvas();
  ConnectorPropertiesPanel props;
  public Sniffer_GUI() {
      super("JConnector demo");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      getContentPane().setLayout(new GridBagLayout());
      init();
  
      getContentPane().add(new JLabel("Connectors example. You can drag the connected component to see how the line will be changed"),
                           new GridBagConstraints(0, 0, 2, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
      getContentPane().add(initConnectors(),
                           new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
      getContentPane().add(props,
                           new GridBagConstraints(1, 1, 1, 1, 0, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.VERTICAL, new Insets(5, 0, 5, 5), 0, 0));
      setSize(800, 600);
      setLocationRelativeTo(null);
  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>I edit to add a code that partially seems to work...</p>
  
  <pre><code>public Sniffer_GUI() {
      super("JConnector demo");
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JPanel container = new JPanel();
      JScrollPane scrPane = new JScrollPane(container);
      add(scrPane);
      scrPane.setLayout(new ScrollPaneLayout());
      init();
  
      add(initConnectors());
  
      setSize(800, 600);
      setLocationRelativeTo(null);
  
  }
  </code></pre>
  
  <p>But it isn't still scrollable, at least it makes its function inside a JScrollPane, is a good step.</p>