I have a JButton which performs an action when clicked. In the actionPerformed I want to update the button text before calling the NotifyObserver, which contains a big number of calculations. The problem is that the buttontext won't update until all the operations called by the NotifyObserver are done. Here's the JButton action code:
//Action for sinoButton
sinoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
sinoButton.setText("Loading Sinogram"); //Set text while loading sinogram
NotifyObserversSinogram(); //Notify observer and start sinogram calculation
}
});
As you can see, the button text should be updated before the observers are notified. Any ideas on how to solve this?