SwingWorker之Task应用一

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.SwingWorker;

public class Test {

	public static void main(String[] args) {
		new Test().go();
	}

	public void go() {
		update();
	}

	public void update() {
		Task task = new Task();
		task.addPropertyChangeListener(new PropertyChangeListener() {

			@Override
			public void propertyChange(PropertyChangeEvent evt) {
			}

		});
		task.execute();
	}
	
	class Task extends SwingWorker<Void, Void> {
		@Override
		public Void doInBackground() {
			System.out.println("1");
			return null;
		}

		@Override
		public void done() {
			System.out.println("2");
		}
	}

}
 

你可能感兴趣的:(java,swing,Go)