I want to add a scrollbar on the side of my Jpanel, itself inside a Jpanel. The scrollbar is displayed but there is no knob in it so I can't scroll.
public class PanelFluxSortant extends JPanel {
public PanelFluxSortant(FluxSortant fs) {
super(new BorderLayout());
makeModel();
parametres = DataManager.getInstance().getParametres();
createComponents(fs);
placeComponents();
initBehaviour();
}
private void placeComponents() {
SpringLayout layout = new SpringLayout();
JPanel paneFS = new JPanel(layout);
JScrollPane scrollPane = new JScrollPane(paneFS);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setPreferredSize(paneFS.getPreferredSize());
paneFS.add( Box.createVerticalStrut(400) );
add(scrollPane, BorderLayout.CENTER);
}
}
On th first picture the scroll bar isn't needed :
[
But here There is some element on the buttom of the rigtht panel. In order to see it I have to enlarge the panel, using the buttom right corner.