问题
i am finding it difficult figuring our how the jcombobox actionperformed event works. I have a form which contains a jcombobox and jtable. Change in jcombobox results in data being updated in the jtable. To implement this, I implemented the actionperformed event for the jcombobox. This code contains certain checks and validations and warnings for users before updating the values in the jtable. The problem I am facing is that when the form loads for the 1st time, the actionperformed event for the jcombobox is getting called. This is causing unnecessary validations and resulting in behaviour which is not required. Can somebody please throw some light on this behaviour of the jcombobox actionperformed event.
回答1:
You have look at ItemListener for handling events from JComboBox, even some description in JComboBox tutorial implements ActionListener
来源:https://stackoverflow.com/questions/8653901/jcombobox-actionperformed-event