我想将在main方法中创建的确切实例传递给具有MPGui作为参数的新Executor。这可能吗?
public class MPGui {
public MPGui() {
//initialize GUI
}
public class ExecuteListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Executor execu = new Executor(MLA, /*the MPGUI() instance */);
execu.execute();
}
}
public static void main(String[] args) {
MPGui a = new MPGui();
}
}
答案 0 :(得分:5)
试试这个(好...... MPGUI.this
实际上):
public class MPGui {
public MPGui() {
//initialize GUI
}
public class ExecuteListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
Executor execu = new Executor(MLA, MPGUI.this);
execu.execute();
}
}
public static void main(String[] args) {
MPGui a = new MPGui();
}
}