In my Swing application, I have two JComboBoxes (energyListSelect and powerRangeSelect). I had like that the 'ActionEvent e' resulting from a selection in one on them (energyListSelect) also triggers the code execution residing currently in of the other one (powerRangeSelect | a 'switch - cases'). More precisely : executing the code corresponding to the selection previously done in that secund JComboBox (powerRangeSelect) (without selection change in it).
Issue : The JComboBox API doesn't offer a 'doClick()' method (like JButton, ...) --> Making an own JComboBox featuring a 'doClick()' method and inheriting from JComboBox.
This solution seems cleaner than adding a layer of methods to my yet heavy code, called by the 'switch - cases' of both of my JComboBoxes and calling themselves the methods that are currently called directly from my JComboBoxes.
But which code should I implement in myComboBox to implement a 'doClick()' method ?
I recall that I need to implement in some cases of the switch of my energyListSelect (JComboBox) a 'powerRangeSelect.doClick();' statement that triggers an 'ActionEvent e' in powerRangeSelect (MyComboBox).
I am not sure what you are trying to do, a bit confused by the description, but this:
Making an own JComboBox featuring a 'doClick()' method and inheriting from JComboBox. This solution seems cleaner than adding a layer of methods to my yet heavy code, called by the 'switch - cases' of both of my JComboBoxes and calling themselves the methods that are currently called directly from my JComboBoxes.
Sounds very much wrong to me. Why is it cleaner to create a new class which only adds a new method (not clear exactly how you would use that method) which doesn't actually describe the action (doClick() simulate clicks, comboboxs produce item selections) instead of creating a single method both action handlers call? But I guess it doesn't matter, I don't think. I think you would be better off creating Actions for the JComboBox. Produce one Action which does the work you want, instead of two ActionListeners. Assign the one Action to both JComboBoxes. Then the Action is invoked whenever either JComboBox is changed. I think that is what you wanted.
Alternately, if you want it to go one way (energyListSelect triggers powerRangeSelect's Action while also doing its own thing, but powerRangeSelect should not trigger energyListSelect's Action) then produce two actions, the EnergyListSelectAction is assigned to energyListSelect, and PowerRangeSelectAction is set to powerRangeSelect as well as passed to EnergyListSelectAction. When EnergyListSelectAction is called it also calls PowerRangeSelectAction.