how to use a button to use selectRegion in java

Asked by wu on 2020-04-24

 i want to use sikuli with java

now i want create a button and the button can use the sikulix the region selectRegion fuction. but i add the method to the button

it not work and when my program done the selectRegion will done

this is my code
     button.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
      System.out.println("Select");
      Region ac = s.selectRegion();
  System.out.println(ac);
      }
});
then wait (5~10s) will appear the selectRegino but is wait to long

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
wu
Solved:
2020-04-28
Last query:
2020-04-28
Last reply:
2020-04-24
RaiMan (raimund-hocke) said : #1

try to run the action code from the event dispatch queue or from a separate asynch thread.

wu (chouhua) said : #2

thx RaiMan i am a new hand use java thanks the Suggest