在actionPerformed中引用此
在主窗口的构造函数中,我使用以下简单代码创建了一个按钮:
JButton jbOptions = new JButton("Options");
buttonsPanel.add(jbOptions);
jbOptions.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
new OptionsDialog();
}
});
现在,我需要将对 JFrame 的引用传递给 OptionsDialog
的构造函数。怎么做呢? this
是对 ActionListener
的引用。
In the constructor of my main window I create a button with the following simple code:
JButton jbOptions = new JButton("Options");
buttonsPanel.add(jbOptions);
jbOptions.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
new OptionsDialog();
}
});
Now, I need to pass to the constructor of the OptionsDialog
a reference to the JFrame. How to do that? this
is a reference to ActionListener
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,
MyJFrame
是封闭类的名称。MyJFrame
being the name of the enclosing class, obviously.