I'm using JScrollPane to put inside a JTable with some values, but the JScrollPane has to be invisible until user clicks on a button. But the JScrollPane remains not visible until I maximise the window manually. I've tried almost everything, .validate(); .revalidate(); .repaint()... I'm using Netbeans, and on the Custom Code of the JScrollPane I've wrote this:
scrollPane = new javax.swing.JScrollPane();
this.scrollPane.setVisible(false);
// El código de los subcomponentes y del gestor de distribución - no se muestra aquí
// El código que agrega el componente al contenedor superior - no se muestra aquí
Then, on MouseReleased:
private void botoGeneraLlistatMouseReleased(java.awt.event.MouseEvent evt) {
    this.generaLlistat();
}
And on the end of generaLlistat():
public void generaLlistat(){{
   ...(Some code requesting data from DB)
   JTable table = new JTable(rows, headings);
   scrollPane.setViewportView(table);
   this.scrollPane.setVisible(true);
   statement.close();
   connection.close();
}
I will appreciate any help :) Thank you all, and sorry about my english grammar and spelling.
 
     
     
     
     
     
     
    