I have added one JPanel
to the JScrollPane
. But the main panel is not scrolling. My problem is like this:
JPanel MainPanel = new JPanel();
MainPanel.setBounds(width/2,height/10,width/5,height/5);
MainPanel.setLayout(null);
JScrollPane scrollPane= new JScrollPane(MainPanel);
scrollPane.setBounds(width/2,height/10,width/5,height/5);
//Added scrollPane to MainFrame Panel
MainFrame.add(scrollPane);
//Added four JPanel to MainPanel
JPanel subPanel1 = new JPanel();
subPanel.setbounds(10,20,50,50);
MainPanel.add(subPanel);
JPanel subPanel2 = new JPanel();
subPanel2.setbounds(50,60,50,50);
MainPanel.add(subPanel2);
JPanel subPanel3 = new JPanel();
subPanel3.setbounds(50,100,50,50);
MainPanel.add(subPanel3);
JPanel subPanel4 = new JPanel();
subPanel4.setbounds(50,60,50,50);
MainPanel.add(subPanel4);
I didn't see the subPanel3
and subPanel4
. Now I'm able to see the vertical scroll bar but it is not working.