1

我需要一个事件被触发,比如说,标签 1 被用户关注。关于如何做到这一点的任何提示?

4

1 回答 1

3

这是我使用的:

tabbedPane.addChangeListener(new ChangeListener() {
private boolean init;

public void stateChanged(ChangeEvent e) {
    if (!init) {                                        
        init = true;

        new SwingWorker<Boolean, Void>() {
            @Override
            protected void done() {
                try {
                    boolean loggedIn = get();

                    if (loggedIn) {
                        // Success so perform tab operations.
                    }
                } catch (InterruptedException e1) {
                    e1.printStackTrace(); // Handle this.
                } catch (ExecutionException e1) {
                    e1.printStackTrace(); // Handle this.
                }
            }

            protected Boolean doInBackground() throws Exception {
                // Perform login on background thread.  Return true if successful.
                return true;
            }
        }.execute();
    }
    }
});
于 2010-09-26T14:34:20.233 回答