Subject: 1.4 Focus Subsystem Help...

J

Jim Crowell

Background:
In my 1.3 version of my App I wrote my own Focus Manager which is working
well but not perfect.I still have problems insuring that I can control the
Focus from my App.

Since I just decided to go to version 1.4.2 I read up on the new Focus
Subsystem and decided to try it.As usual, for me, I am unable to get it to
do what I want.

Requirements:
I have a custom class [JFormField] that extends JPanel and contains 2 or 3
components as follows:

Type 1: JPanel contains a JLabel and a Java Component [e.g. a JTextField].
Type 2: JPanel contains the Type 1 components followed by a JButton.

The JButton is not focusable. It is invoked by the end user via keyboard
binding [Alt/H] or a mouse click.

The JLabel is by definition not focusable.

The Java Component [c] is selected via a mouse click or via a TAB from
another instance of JFormField. It may also be selected via the App itself.

Multiple JFormField instances are inserted into a JPanel [formPanel] in the
order that they should be processed. The JFormField Class sets the host
JPanel to be focusable.

Problem:
I need to keep the focus in the JFormField instance until I have processed
pre and post processor methods on the JFormField Java Component [c].

I have setup a Focus Listener on the Java Component and gain the required
control via the "focusGained" and "focusLost" Methods.

NOTE: The Focus Listener is an Inner Class hosted by the JFormField Class.

After processing the 'pre Processor' via the 'focusGained' I need to let my
end user enter data into the Java Component [c] before the 'post Processor'
operation shall be invoked.

This is where I loose it. I've tried many different combinations but
invariably the focus gained method is invoked at the wrong time for the next
JFormField in the 'formPanel'.

I think what I need is some way to hold off the FocusTraversablePolicy of
the parent JPanel [formPanel] until I have accomplished my 'post Process'
requirement.

I do not see how to do that.

Any suggestion?

Thanks
Jim...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top