EventQueue.invokeLater(new Runnable() { public void run() { calculateButton.setText("Calculate"); calculateButton.setEnabled(!table.getSelectionModel().isSelectionEmpty()); } });
			public void actionPerformed(ActionEvent e) {				if (calculating) {					calculateButton.setText("Calculate");					calculateRemaining = false;					calculateButton.setEnabled(false);				} else {					calculateButton.setText("Do not calculate remaining");					calculateRemaining = true;					final List indices = new LinkedList(); 					for (int i = 0;	i < sorter.getRowCount(); i++) {						if (table.getSelectionModel().isSelectedIndex(i)) {							//evalsModel.calculate(sorter.modelIndex(i));							indices.add(new Integer(sorter.modelIndex(i)));						}					}					new Thread(new Runnable() {						public void run() {							calculating = true;							console.append("\nCALCULATION:\n\n");							Iterator it = indices.iterator();							while (it.hasNext() && calculateRemaining) {								int rowIndex = ((Integer)it.next()).intValue();								console.append("Calculating '" + evalsModel.getValueAt(rowIndex,0) + "'"										+ "  ["+(rowIndex+1)+"/"+indices.size()+"] ...");								evalsModel.calculate(rowIndex);								console.append(" done.\n");							}							calculating = false;						}					}).start();				}			}