I have this problem.
I've already added JPanel to JScrollPane but the scrollbar is not working
Here is my code for JPanel and some picture:
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(null, "Choose table",
TitledBorder.LEADING, TitledBorder.TOP, null, null));
panel.setLayout(null);
// Add 10 table
for (int i = 1; i <= 15; i++) {
JLabel ban = new JLabel(new ImageIcon(getClass().getResource("/images/table-32-green.png")));
ban.setOpaque(true);
ban.setText("Table " + (i));
ban.setBounds(20, (5 + 70) * i, 65, 60);
ban.setHorizontalTextPosition(SwingConstants.CENTER);
ban.setVerticalTextPosition(SwingConstants.BOTTOM);
panel.add(ban);
}
And here is my JScrollPane:
JScrollPane scrPane = new JScrollPane(panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrPane.setBounds(10, 51, 974, 488);
scrPane.setBorder(BorderFactory.createEmptyBorder());
getContentPane().add(scrPane);
And here is the picture, there's no scrollbar
Please help, thank you very much!