I created a little program where i have a JFrame with a JScrollPane. In this JScrollPane there is a panel (where i set the Viewportview) with different JButtons. I set my setBounds, set null to the layout of the panel but i can't see the jscrollbar.
JFrame jf = new JFrame("My Frame");
//other things of the frame...
JScrollPane jsp = new JScrollPane();
jsp.setBounds(0,83,301,667);
JPanel jp = new JPanel();
jp.setLayout(null);
JButton jb = new JButton("Button 1");
jb.setBounds(0,0,40,1500) //here there is only 1 button, a big button
jp.add(jb);
jp.revalidate();
jp.repaint();
jsp.setViewportView(jp);
And here is where i can't see the jscrollbar, it work only if I set the layout:
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
But with this layout i can't set my setBounds and everything is put below the previous component. Thanks and sorry for my bad english