How to detect focus lost on a JPanel
- From: clearlight@xxxxxxxxx
- Date: 16 Apr 2007 20:24:10 -0700
Hi,
I am new to Java. As a basic learning project, I started writing a no-
frill small general ledger application.
The basic design is a Frame containing a menu and a JTabbedPanel. When
a menu option is selected, a component derived from JPanel containing
the graphical interface for the data entry of the selected option is
created, added to the JTabbedPane component and the corresponding Tab
is selected.
Inside any of this panels, there are JTextFields that have to be
validated (via InputVerifiers).
Now, if focus is inside any of this JTextFields, and I select a new
option from the frame's menu, validation shouldn't be fired.
So far, I have tried to add a FocusListener to the JPanel descendents,
but it doesn't work as I expected: JPanel fires a focusLost event when
focus enters a JTextField contained within the panel itself, and fires
nothing when a menu option is selected.
If I establish a dependency between the main JFrame and the contained
JPanel derivates, I might perhaps design a sort of bidirectional
notification protocol, but I would like to avoid any dependence that
can be avoided.
So, is there a standard event that lets me know when the focus leaves
a JPanel (FocusListener doesn't work, because -at least in my
configuration: NetBeans 5.5, JDK 1.6, WinXP- it fires when a control
within the panel gains focus)?
TIA
.
- Follow-Ups:
- Re: How to detect focus lost on a JPanel
- From: Ian Wilson
- Re: How to detect focus lost on a JPanel
- Prev by Date: Re: how do i put an image as a background on a JFrame?
- Next by Date: menus
- Previous by thread: how do i put an image as a background on a JFrame?
- Next by thread: Re: How to detect focus lost on a JPanel
- Index(es):