Pessoal estou tentando criar um panel com muitos componentes em tempo de execução mas aparece o scroll vertical com o restante dos componentes.
help me.
gracias.
public FormRestricao(Relatorio relatorio) {
super();
initComponents();
// this.setLayout(new GridBagLayout());
this.relatorio = relatorio;
this.jPanel1.setLayout(new GridBagLayout());
JScrollPane scroll = new JScrollPane(this.jPanel1);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.setAutoscrolls(true);
// this.jPanel1.add(scroll);
this.getContentPane().add(scroll);
//preenche o panel com os components
preencheColunaNovasClasses();
preencheFormComp();
this.jPanel1.setSize(this.jPanel1.getPreferredSize());
this.jPanel1.repaint();
this.repaint();
this.setModal(true);
this.setVisible(true);
}