I have a Swing application, in which initial JFrame (frame
) has one JPanel (firstPanel
) with one button. On clicking this button, the JFrame should remove firstPanel
and add a new JPanel (secondPanel
). There is one simple JLabel (lab
) in secondPanel, whose text will be based on some calculation which might take some time.
Right now, secondPanel
gets initialized only after the calculation is completed. I want to initialize secondPanel
with empty label initially. Calculation should be done in parallel and content of label should be changed when calculation is completed. How can I do this?