I have a JPanel that contains a JScrollPane that contains a JTable. Inside my panel constructor it's created this way:
//inside MyPanel extends JPanel class constructor
public void MyPanel(){
TitledBorder border = BorderFactory.createTitledBorder("title");
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.scrollTable = new JScrollPane(table);
this.scrollTable.setBorder(border);
}
Now, the user should be able to load another table into application so I need to remove the previous one from the scrollpane and add a new one. I've tried the following :
public void setNewTable(JTable t ) {
this.scrollTable.removeAll();
this.scrollTable.add(t);
this.scrollTable.validate();
}
The previous table is removed, but nothing happear inside the JScrollPane now.
What am I doing wrong?
public void