I have created jframe in which jpanels are added dynamically
what i can’t do is scroll down to all the panels which are created.
pls suggest me how to use scroll bar/scrollpane to scroll down the multiple panels.
here is my code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.border.Border;
import sun.swing.FilePane;
public class Test extends JFrame
{
public Test()
{
getContentPane().setLayout(new FlowLayout());
addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowClosing(java.awt.event.WindowEvent evt)
{
System.exit(0);
}
});
for(double i=10000000;i<90000000;i++)
{
if(i%10000000==0)
{
getContentPane().add(new z());
validate();
}
}
setSize(1024,1024);
setVisible(true);
}
public static void main(String args[])
{
new Test();
}
}
in above code z is class which extends jpanel which have 3 labels and 2 buttons
pls tell me how to scroll down through these panels
or how i can view all the panels?
Recommendations
revalidate()andrepaint()the container JPanel whenever components are added or removed.