There is an array of buttons to which a handler with complex logic is registered.

for(int i = 0; i < 10; i++){ for(int j = 0; j < 10; j++){ MyButton b = new MyButton(); b.setBackground(Color.white); b.setLocation(i, j); b.addActionListener(CellListener.getInstance()); b.setBounds(40+j*20, 40+i*20, 20, 20); this.add(b); arrayCell.add(b); } } 

How can you force events from these buttons from another place of the program to test the logic of the attached listener?

  • Judging by the en-SO you need doClick() - Yuriy SPb
  • @ ЮрийСПб Thanks! everything worked - Roman Markov
  • @ YuriySPb can, as an answer, issue your comment?) - Denis
  • @Denis, and this was the answer) It was just that the system itself was altered as too short in the commentary ( - YuriySPb

1 answer 1

Judging by the en-SO, you need the doClick() method, which will make a software click on the button