title: remove borders inside JScrollPane
body: <p>I'm trying to put multiple JLists in a JPanel and the JPanel in a JScrollPane. The problem is that when I add the JScrollPane to the equation there is a space between the JList and outer border, how do I get rid of this border so it's fills horizontally?</p>
  
  <p>Here is a small sample code that demonstrates this problem with a JLabel instead of JList.</p>
  
  <p><strong>/edit: It's seems to be windows thing, it runs fine on Mac OS.</strong></p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  
  public class Test extends JFrame
  {  
      public static void main(String[] args) 
      {
          Test test = new Test();
      }
  
      public Test()
      {
          JPanel contentPane = new JPanel();
          contentPane.setLayout(new BorderLayout());        
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);        
          this.setContentPane(contentPane);        
          this.setMinimumSize(new Dimension(400, 300));
  
          JScrollPane sp = new JScrollPane(createLeftPane());
          sp.setBorder(BorderFactory.createLineBorder(Color.yellow));
          this.add(sp, BorderLayout.WEST);
  
          LookAndFeel.installBorder(sp, "BorderFactory.createEmptyBorder()");        
  
          StackTraceElement[] st = Thread.currentThread().getStackTrace();
          for(int i = 0; i &lt; st.length; i++) {
              System.out.println(st[i]);
          }
  
          this.pack();
          this.setLocationRelativeTo(null);
          this.setVisible(true);
  
      }
  
      private JPanel createLeftPane()
      {
          JPanel panel = new JPanel();
          panel.setLayout(new GridBagLayout());
          GridBagConstraints c = new GridBagConstraints();
          c.fill = GridBagConstraints.HORIZONTAL;
          JLabel label = new JLabel("TEST LABEL");
          label.setBorder(BorderFactory.createLineBorder(Color.blue));
          panel.add(label, c);
          panel.setBorder(BorderFactory.createLineBorder(Color.red));
  
          return panel;
      }        
  }
  </code></pre>
  
  <p>Here's a screenshot (first one is without the scrollpane)
  <img src="https://i.stack.imgur.com/Gt5Uz.png" alt="JScrollPane Problems"></p>
  
  <p>Stack Trace:</p>
  
  <pre><code>java.lang.Thread.getStackTrace(Thread.java:1479) 
  test.Test.&lt;init&gt;(Test.java:27) 
  test.Test.main(Test.java:10)
  </code></pre>
  
  <p><strong>/edit: After some trial and error I found out that when I add a c.weightx = 0.5 to the contrains it does fill Horizontally, but when the scrollPane becomes larger than it's content it makes itself wider, which is weird. See the screenshots below:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/jFGS2.png" alt="enter image description here"></p>