Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7044503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:25:03+00:00 2026-05-28T02:25:03+00:00

Is it possible to install filter for events for all controls placed in some

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:25:04+00:00Added an answer on May 28, 2026 at 2:25 am

    In jdk7 you can use JLayer to decorate any component with listeners:

        LayerUI<JComponent> ui = new LayerUI<JComponent>() {
    
            @Override
            protected void processMouseEvent(MouseEvent e, JLayer<? extends JComponent> l) {
                 System.out.println(e.getSource().getClass() + " at " + e.getPoint());
            } 
        };
        JLayer<JComponent> layer = new JLayer<JComponent>(mainPanel, ui);
        layer.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK );   
    

    (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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m thinking about trying some development for the iPhone, is it possible to install
Is it possible to install two different versions of PHP in the same computer?
Is it possible to install two different applications with same package name in my
I have a shared hosting account, is it possible to install LAME onto my
Is it possible to install a keyboard filter driver(like ctrl2cap) while windows is running
I have an installshield project is it possible to install redistributable packages after the
Is it possible to install/register another local server instance in any SqlServer version, besides
Is it possible to install the x86 Remote Debugger as a Service on a
Is it possible to install sql server 2005 express and sql server 2008 developer
Is it possible to install gcc in iPhone (3.0 or above) with out jailbreaking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.