How to avoid firing actionlistener event of JComboBox when an item is get added into it dynamically in java?

后端 未结 9 2286
广开言路
广开言路 2020-12-04 00:23

I need your suggestions and guidence on following task.

I have a frame which has two JComboBoxes supposed they are named combo1 and combo2, a JTable and other compon

9条回答
  •  难免孤独
    2020-12-04 00:47

    try this:

           indicatorComboBox = new JComboBox() {
    
            /**
             * Do not fire if set by program.
             */
            protected void fireActionEvent() {
                // if the mouse made the selection -> the comboBox has focus
                if(this.hasFocus())
                    super.fireActionEvent();
            }
        };
    

提交回复
热议问题