如何在同一个class中调用一个接口方法?

how to call an interface method in the same class?

我在 class 中创建了一个界面。我想在同一个 class 中调用此接口的一个方法,并将参数传递给它

public class NewArticle extends JFrame {
    interface NewArticleEvent{
        public void addarticle(String name ,String category,String B);        
    }
   .
   .
   .
    JButton add= new JButton("add");
    add.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            /* I want to call 'addarticle' method here * /

        }
    });
   .
   .
   .
}

我想在这里使用我定义的 3 个参数调用我的方法 addarticle

因为我想在另一个 class.

中将此方法与这些参数一起使用

您需要传递 NewArticleEvent 的实例才能使用它的方法。

一个解决方案可能是将实现 NewArticleEvent 的对象传递给 NewArticle class 并在需要时调用该方法。更多代码将不胜感激。