<AWT Dev> Global InputVerifier

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

<AWT Dev> Global InputVerifier

Reto Merz-2
Hello,

We try to prepare our WebStart-based app for Java 9.
It is very important that we can perform validation on every focus change and reject it if needed
based on which target component will be focused.
At the moment we use sun.awt.RequestFocusController which is invoked on every focus change
and provides the source and the *target* component (which would be finally focused)
if acceptRequestFocus returns true.

I have already request an API for this:
http://mail.openjdk.java.net/pipermail/awt-dev/2016-April/011076.html
https://bugs.openjdk.java.net/browse/JDK-8154431

The extended InputVerifier with the new method verifyTarget works as expected.
But the problem is that we need to set the InputVerifier on *every* JComponent that is created
because it is possible that this components owns the focus just before one of *our* component gets focused.
This is not practicable because our app also contains complex third-party components like a HTML editor.
Such third-party components are composed of several focusable components like a font-combobox in case of the HTML editor
and of course they can dynamically create/remove additional components.

So in our case what we need is to register a global InputVerifier which is invoked
on every focus change.

Thanks
Reto