• Post Reply Bookmark Topic Watch Topic
  • New Topic

different behaviour of requestFocus in jdk1.3 and jdk1.4  RSS feed

 
Tauqueer Ali
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I'm developing an application that contains a JTable and a few of its columns contain.
JTextField. On jdk 1.4 if you click on one cell to start an edit and
then click on another cell to start an edit the second edit does not
begin and likewise the problem occurs alternatively. This is because the
focus alternates between the JTable and JTextField in jdk 1.4 whereas on
jdk 1.3 the focus is always on JTextField and it works fine on jdk1.3

I tried using JTextField.requestFocusInWindow() method. The API docs mention that
"Requests that this Component get the input focus, if this Component's top-level ancestor is already the focused Window. This component must be displayable, visible, and focusable for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.
This method returns a boolean value. If false is returned, the request is guaranteed to fail. If true is returned, the request will succeed unless it is vetoed, or an extraordinary event, such as disposal of the Component's peer, occurs before the request can be granted by the native windowing system. Again, while a return value of true indicates that the request is likely to succeed, developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.
"
In my application
requestFocusInWindow is returning true.
but hasFocus() returns false.
Now according to the docs quoted above, it is probably due to the disposal of Component's peer.
This statement is not clear to me.
Does anybody know of any workaround for this problem on jdk1.4?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!