Make all you *UI classes implements the same interface :
public interface XMLWritable {
void writeToXml();
}
public class HouseGUI implements XMLWritable {
public void writeToXml() {
//XML writing stuff
}
}
----
for (int i = 0; i < totalTabs; i++) {
if(tabbedPane.getComponentAt(i) instanceof XMLWritable ) {
((XMLWritable) tabbedPane.getComponentAt(i)).writeToXml();
}
}
To conclude, it is not very maintainable to mix UI and persistence stuffs, but it is not the purpose of your question.