I have a short question. I tried to google it, but it seems, that I can't find the correct keywords for good results. So here is my problem:
I have a JButton. Its actionPerformed is doing this:
public void actionPerformed(ActionEvent e) {
lblConverting.setVisible(true);
input.writeToCSV(chosenPath);
lblConverting.setVisible(false);
lblSuccess.setVisible(true);
}
Due to the long execution of my writeToCSV
-method, I want to show a message, which my lblConverting
contains. So during the execution of writeToCSV
the user should see a message, which tells him to wait some minutes. Instead it looks like, that lblConverting
gets visible "too late", so that it is set invisible shortly after writeToCSV
is finished, right before it gets invisible again.
So, is there a way to get that label visible, before the method executes? Should I use something like SwingWorker? The first line of the actionPerformed
is the only place in my code, where I want to do this. So a really short solution is preferred.