In my application, the first time a panel gets displayed, there is noticeable UI lag in displaying it. Every time after the first, it is displayed fast and there is no lag.
I am assuming this is because it has to do its initial paint or whatever it does under the hood. Is there a way I can render/paint all my panels before showing them, such as during application start?
I am using a Card layout to show my panels like so:
public void showCard(final String card) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
CardLayout layout = (CardLayout) window.getContentPanel().getLayout();
layout.show(window.getContentPanel(), card);
}
});
}