JPanel is not updated when I click on button

Hello. I have a JPanel that must redraw several lines when a click on a button after downloading from on-line server has been completed. The problem is that the data is downloaded, new data is sent to the instance of the JPanel class, but the panel is not updated/redrawn. If I change the size of the frame, it redraws as needed. Or if I go to another panel and then return, it redraws it. Looks like paintComponent() is not invoked when I do revalidate() or repaint():

Re: JPanel is not updated when I click on button

I don't see where you add the panel to the JFrame. And you should not be extending JFrame. Just use a JFrame instance. Actually,
you don't show much of anything. You should do what Norm asks. Make a complete working program to demonstrate the problem.
That means "we" can easily compile it with no syntax or compiler errors.

Re: JPanel is not updated when I click on button

I have tried to write a simple example showing the problem (the original question has been updated). You download data on the second card and the JPanel is not updated (lines are not drawn). You go back to the first card and then again to the second card and the lines are shown as expected. This is my console output:

Re: JPanel is not updated when I click on button

If it is not needed here, where else? By the way, I have written a similar application in Swift and used a delegate to notify my view controller when to update the panel view. Here, I am completely at a loss. Cheers.

Re: JPanel is not updated when I click on button

If you haven't already done so, I would suggest you put print statements in strategic places to see if your button events are firing correctly. At the same time you may want to see if repaint is working as expected and if the data is there. And in case you didn't know, painting requires you to save subsequent data if you want it all displayed for each refresh. So whatever you painted before, will be gone unless you repaint it plus any new data.

Also, on line 187 you create an anonymous class of ComponentListener. If you use ComponentAdapter, you won't have to provide the unimplemented method bodies.

Re: JPanel is not updated when I click on button

Some suggestions:
Don't extend JFrame, create an instance of JFrame and use it.
Pass a reference to the MainFrame class to the class that needs to calls its methods
or move the displayWindsAloft method to another class.
Is the displayWindsAloft() method in the right class?

Re: JPanel is not updated when I click on button

You create a new instance here, and then call the display method.
However that is not the MainFrame that is currently displayed.

indeed that new MainFrame is never displayed.
Because the panel you expect to see is associated with this invisible Frame then it to is never displayed, so a call to repaint does nothing...there's nothing visible so Swing doesn't bother doing any painting.

This is not a terribly well constructed Swing app, but that is one of the side effects of using the GUI builder without really understanding Swing...and the GUI builder.
Your app tends to become an unstructured blob of code.

You ought to have a controller (or controllers) in there that manages all of this, from the navigation between panes to the acquiring of data.