jcombobox actionperformed事件 [英] jcombobox actionperformed event
问题描述
我发现很难弄清楚我们jcombobox的actionperform事件如何工作。我有一个包含jcombobox和jtable的表单。 jcombobox中的更改导致jtable中更新的数据。为了实现这一点,我为jcombobox实现了actionperformed事件。在更新jtable中的值之前,此代码包含用户的某些检查和验证和警告。我遇到的问题是,当表单第一次加载时,jcombobox的actionperformed事件被调用。这导致不必要的验证,并导致不需要的行为。有人可以对jcombobox actionperformed事件的这个行为给出一些看法。
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.
推荐答案
你看过 ItemListener 用于处理来自JComboBox的事件,甚至在 JComboBox教程实现 ActionListener
You have look at ItemListener for handling events from JComboBox, even some description in JComboBox tutorial implements ActionListener
这篇关于jcombobox actionperformed事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!