0

Suppose I have JFrame with one button on it, and JDialog which should have reference to that JFrame. When user clicks on button, I need to open JDialog, but I need to pass this which is referencing JFrame. So I made action listener on that button, but I cannot use this in that context, because it is referencing action listener, not a JFrame( which is logical, because it is in listener block). Any suggestion?

public class App extends JFrame{
private JButton btnAdd;
public App(){}
btnAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
       AppDialog app =new AppDialog (this); // this cannot be used here
        }}
 public class AppDialog extends JDialog {
App app;    
public AppDialog(App app){
this.app = app;}
}
mp94
  • 11
  • 1
  • 7

0 Answers0