<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The FocusTraversalPolicy can be obtained using public API. It may
give you the target. But I believe this is not what you would like
to do...<br>
<br>
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
It seem sensible to make
Component#requestFocusInWindow(CausedFocusEvent.Cause cause) public.
Will it be enough for you?<br>
<br>
I could start to implement this right after the 8080395 push.<br>
<br>
--Semyon<br>
<br>
<div class="moz-cite-prefix">On 4/14/2016 12:30 PM, Reto Merz wrote:<br>
</div>
<blockquote
cite="mid:6217cdd6-cef9-4509-8025-342ca650b075@abacus.ch"
type="cite">
<pre wrap="">Hello Semyon,
We need to know the target component: "which component will be focused".
Target component means the component which should be "really" focused,
so this can only be known after all the FocusCycle / FocusTraversalPolicy logic has processed.
DefaultKeyboardFocusManager focusNextComponent/focusPreviousComponent
provides only the source component. Not the target.
The second argument of RequestFocusController#acceptRequestFocus is the "real" target component.
We use only this argument in our custom RequestFocusController implementation.
Thanks
Reto Merz
On 14/04/16 08:31, Semyon Sadetsky wrote:
Hi Reto,
It is unlikely that AWTAccessor API may be opened. It gives access to internal undocumented methods not to even mention that those methods have private and package accesses.
As I understand you need the way to intercept focus transfer initiated by a traversal key. Why to subclass the DefaultKeyboardFocusManager to override its focusNextComponent/ focusPreviousComponent methods?
--Semyon
On 4/12/2016 2:37 PM, Reto Merz wrote:
Hello Alexandr,
Basically we need to detect and intercept focus changes.
java.awt.Component allows to override this methods:
requestFocus()
requestFocus(boolean)
requestFocusInWindow()
requestFocusInWindow(boolean)
requestFocus() is only invoked when the component is focused by a mouse click.
But no requestFocus* method is invoked when a FocusTraversalPolicy is involed
(f. e. the user press TAB to focus next component).
sun.awt.RequestFocusController#acceptRequestFocus is invoked in both cases.
Attached a demo to reproduce it:
- if TextField is focused by a mouse click "requestFocus" and "acceptRequestFocus" is logged
- if TextField is focused by TAB only "acceptRequestFocus" is logged
Some more notes about the test program:
ComponentAccessorDelegator delegates all calls to the original ComponentAccessor implementation.
Only ComponentAccessor#setRequestFocusController is changed to keep our RequestFocusController implementation.
I have just filled a RFE on <a class="moz-txt-link-freetext" href="http://bugreport.java.com/bugreport">http://bugreport.java.com/bugreport</a>
Thanks
Reto Merz
On 11/04/16 21:02, Alexander Scherbatiy wrote:
Hello Reto,
Could you provide use cases which illustrate tasks the requested API is intended to solve in your application?
Please, also create a request in the bug system <a class="moz-txt-link-freetext" href="http://bugreport.java.com/bugreport">http://bugreport.java.com/bugreport</a>
Thanks,
Alexandr.
On 11/04/16 12:26, Alexander Scherbatiy wrote:
Resending the request to awt-dev alias.
Thanks,
Alexandr.
On 4/4/2016 4:54 PM, Reto Merz wrote:
Hello,
Jigsaw will disallow access to internal packages.
We have written a complex validation and focus management
implementation for our closed-source RIA and maintain it since JRE
1.4.
For this we use some internal API. We have a custom implementation of
these interfaces:
sun.awt.RequestFocusController
sun.awt.AWTAccessor.ComponentAccessor
And use this getter and setter:
sun.awt.AWTAccessor#setComponentAccessor(AWTAccessor.ComponentAccesso
r)
sun.awt.AWTAccessor#getComponentAccessor()
sun.awt.AWTAccessor.ComponentAccessor#setRequestFocusController(Reque
stFocusController)
Please make this API public.
Furthermore we need to call
java.awt.Component#revalidateSynchronously().
We do this with reflection. It would be nice to have a public API for
this.
Maybe a new static method on AWTAccessor:
AWTAccessor.revalidateSynchronously(Component)
Best Regards
Reto Merz
</pre>
</blockquote>
<br>
</body>
</html>