Passing Arguments to ActionListener

前端 未结 1 1458
鱼传尺愫
鱼传尺愫 2021-01-29 12:11
public class start implements ActionListener {

    public void actionPerformed(ActionEvent aL) {
      method(arguments);

    }
  }

method(arguments) {
   //stuff
}
<         


        
相关标签:
1条回答
  • 2021-01-29 12:48

    You can pass the arguments by constructor. But of course it means with this way you can pass the arguments only when creating the ActionListener.

    public class Start implements ActionListener {
    
        SomeType arguments;
        public Start (SomeType arguments) {
             this.arguments = arguments;
        }
    
        public void actionPerformed(ActionEvent aL) {
            method(arguments);    
        }
    }
    
    0 讨论(0)
提交回复
热议问题