开发者

Swing JComboBox not reloading while switching the Jtabbedpane

开发者 https://www.devze.com 2023-04-08 11:54 出处:网络
I am trying to re initialize the JComboBox while tab switches from data updating page to page containing JComboBox

I am trying to re initialize the JComboBox while tab switches from data updating page to page containing JComboBox my function is like this and it is called as well but doesn't work....

private void jTabbedPane2StateChanged(javax.swing.event.ChangeEvent evt) {
    S开发者_JAVA技巧ystem.out.println("State change called");
    String[] categories=controller.getCategories();
    ComboBoxModel cmbModel1=new DefaultComboBoxModel(categories);
    jComboBox1.setModel(cmbModel1);
    jComboBox1.validate();
}


It seems that controller.getCategories() always returns the same results.

Try to rather use the focusGained event for the tab where your combo resides. The stateChanged event occurs with every tab click you make.

kingo is right with his comment, since can only guess when the code is incomplete.

0

精彩评论

暂无评论...
验证码 换一张
取 消