I have a JFrame in which i have added two JPanel with JScrollPane, one in half part of JFrame vertically.
then i am adding a no. of JPanel(each Containing two JLabel in flowlayout) to these two JPanel.
up to this every thing is fine , But when no. of JPanel increases, size of JPanel decreases while Scrolling does not working.
could you help me to finding out why scrolling is not working.
Here is some code with only one JPanel
class scrol extends JFrame
{
scrol()
{
//getContentPane().setLayout(new GridLayout(1,2));
JPanel p1=new JPanel();
p1.setLayout(new GridLayout(0,1));
p1.setPreferredSize(new Dimension(300,350));
int n=1;
p1.setBorder(BorderFactory.createLineBorder(new Color(200,167,0)));
JScrollPane scrol1=new JScrollPane(p1);
scrol1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
//scrol1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrol1.setBounds(0,0,420,405);
getContentPane().add(scrol1,BorderLayout.CENTER);
while(n<100)
{
n=n+1;
p1.add(new JPanel().add(new JLabel("hello")));
}
pack();
setSize(500,500);
setVisible(true);
}