Creating a new JComponent with event actionPerformed

Posted on 2006-06-01
Last Modified: 2008-03-06

I would need help on this. I have created a JComponent that has JTextField, JButton and another class for popup. So it is works much like a JComboBox, except the popup is not a JList. I would like to fire actionPerformed event from my own component class like JButton do, so I could catch the event from the class that uses the component.

Question by:JamixOy
    LVL 86

    Assisted Solution

    LVL 14

    Accepted Solution

    component.dispatchEvent(new ActionEvent(component, ActionEvent.ACTION_PERFORMED, null));

    Author Comment

    Hi CEHJ and hoomanv,

    Both solutions worked fine.

    Thank you.

    / mika
    LVL 86

    Expert Comment


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now