Link to it actionPerformed

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(); } }); 

I now need to pass to the constructor OptionsDialog link to JFrame. How to do it? this is a reference to ActionListener .

+4
source share
1 answer
 new OptionsDialog(MyJFrame.this); 

MyJFrame , obviously, is the name of the enclosing class.

+4
source

Source: https://habr.com/ru/post/1391996/


All Articles