title: How to layout a components in vertical only scrollpane?
body: <p>I have a complex question I cant find an answer anywhere.</p>
  
  <p>here is a example : </p>
  
  <pre><code>public static void main(final String[] args) {
      final JFrame frame = new JFrame("test");
      final JPanel bigPane = new JPanel(new GridLayout(0, 1));
      frame.setContentPane(new JScrollPane(bigPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
              ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
      bigPane.add(new JTextField("reterterter ertertrert erterter ert"));
      bigPane.add(new JTextField(" ertertrert erterter ert"));
      bigPane.add(new JTextField("reterterter ertertrert  ert"));
      bigPane.add(new JTextField("reterterter ertertrert erterter "));
      frame.pack();
      frame.setSize(frame.getSize().width/2, frame.getSize().height);
      frame.setVisible(true);
  }
  </code></pre>
  
  <p>Here, clearly the textfields are cut. More precisely, bigPane is cut. But I would like the textfields to be resized instead of cut, so we can still use them.</p>
  
  <p>Since the horizontal scrollbar is forbidden to appear, I would like the layout to forget the view's (bigPane) preferred width and always force the view's width to match the viewport's width. Like there would be no virtual viewport for the horizontal direction, only in the vertical.</p>
  
  <p>I can't find a solution to that, and not even a hack, thaks if you can help.</p>
  
  <p>Nico.</p>
  
  <p>PS: looks like the code for ViewportLayout doesn't contain any code for that</p>
  
  <p>PS2 : here is a cap of the result of the above code <a href="http://www.nraynaud.com/kilombo/testLayout.png" rel="nofollow noreferrer">http://www.nraynaud.com/kilombo/testLayout.png</a> see the right side.</p>