jcombobox actionperformed event

百般思念 提交于 2020-01-25 10:52:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!