czArek czArek - 2 months ago 12
HTML Question

The fastest way to perform a click in Java

I used SWT Browser in my Java project.

I get content of page by JavaScript, next get button which I need to perform to click by Java code.

Now I do this from Java code like below:


is object from lib

But I am not sure that is the fastest way to click. I care as soon as possible to click on button.

Is there any fastest way to perform click on button ?

Away from graphic click, maybe by fire event ?

I'm comparing it by example when I call method
on button in Java it cost about 100ms (by graphics thread and do click on button) and when I used
it cost 0ms !

Baz Baz

I'd recomment to just go with click().

You're analogy with the Swing listener is flawed, because it's not as easy as you make it out to be:

  1. What if there's no action listener at all?
  2. By passing null you loose information, etc.

I don't think the gain in performance balances out the downsides.

The same will be the case for Javascript. There are too many things that can go wrong by trying to invoke listeners (if exist) manually and the performance improvement (if any) you get from it isn't that great either.