Is it possible to install filter for events for all controls placed in some container?
For example I have a panel where two buttons live and one panel with two text boxes, I want to be able to receive all events that go to these controls (buttons and text boxes).
UPD
There are four controls:
JPanel mainPanel = new JPanel(new BorderLayout());
JButton b1 = new JButton();
JButton b2 = new JButton();
mainPanel.add(b1, BorderLayout.WEST);
mainPanel.add(b2, BorderLayout.EAST);
JPanel childPanel = new JPanel(new FlowLayout());
JTextField txt1 = new JTextField();
JTextField txt2 = new JTextField();
childPanel.add(txt1);
childPanel.add(txt2);
mainPanel.add(childPanel, BorderLayout.SOUTH);
EventDispatchingMachine.attachEventListener(mainPanel, listener);
where listener receives all events that go to b1, b2, txt1, txt2. Ideally every event that could be processed via listener on specific control (e.g. b1.addActionListener(asd)) I want to receive in listener.
In jdk7 you can use JLayer to decorate any component with listeners:
(for jdk6, there’s the project JXLayer which supports the same)
Edit
on second reading of the question, the answer could be “not possible”: event != event. You can (via a LayerUI or manually AWTEventListener) register to receive all events that are globally dispatched. You cannot hook into “locally” dispatched events, as f.i. actionEvents which are simply used as parameters to a known callback method which is called directly by the sender.