Solved

JComboBox changed event

Posted on 2004-10-29
230 Views
Last Modified: 2011-09-20
I thought that the ActionPerformed() would fire an event if I changed the selection in a combo box, however fires even when the component is loaded.  What event do I use to fire only when  user makes a selection?

Thanks,
David
0
Question by:lomidien
    6 Comments
     
    LVL 37

    Expert Comment

    by:zzynx
    You should use actionPerformed()
    0
     
    LVL 37

    Expert Comment

    by:zzynx
    >> however fires even when the component is loaded
    I use a flag to skip the changes when loading
    0
     
    LVL 37

    Accepted Solution

    by:
    boolean skipChanges = false;


    skipChanges = true;
    // fill up the combobox and make initial selections
    skipChanges = false;


    public void actionPerformed(ActionEvent evt) {
       if (skipChanges) return;

       // do what you want
    }
    0
     

    Author Comment

    by:lomidien
    Perfect, thanks a bunch.

    David
    0
     
    LVL 37

    Expert Comment

    by:zzynx
    >> however fires even when the component is loaded.
    Rather logical after a second thought, since loading the component = selecting the first item in it
    0
     
    LVL 37

    Expert Comment

    by:zzynx
    You're welcome
    Thanks for accepting :°)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT Security CISA, CISSP & CISM Certification

    Master the advanced techniques required to protect network resources from external threats with the IT Cyber Security bundle. Built around industry best-practice guidelines, the IT Cyber Security bundle consists of three in-depth courses.

    Suggested Solutions

    Title # Comments Views Activity
    Deactivate - DEBUG print on console 2 20
    java JDK Download 7 35
    powerN  challenge 3 20
    nestparen challenge 4 14
    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 first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    913 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

    14 Experts available now in Live!

    Get 1:1 Help Now