2 Replies Latest reply: Mar 21, 2012 7:20 AM by 800268 RSS

    Strange implemention for JComboBox.

    925326
      In JComboBox maintenance a listen list to handle the event Item change event, also in model(AbstractListModel) maintenance another listen list to handle List Data change event. See these two is duplicated. You can see JList, JTree other components all is only maintenance one list in model.

      Hi Guys, can some one explain this? Thanks.
        • 1. Re: Strange implemention for JComboBox.
          EJP
          In JComboBox maintenance a listen list to handle the event Item change event
          'itemStateChanged(ItemEvent e) is invoked when an item has been selected or deselected by the user.'
          also in model(AbstractListModel) maintenance another listen list to handle List Data change event.
          If you mean ListDataEvent, it is invoked when the application changes the contents of the list.
          See these two is duplicated.
          No they aren't. They are different things.
          You can see JList, JTree other components all is only maintenance one list in model.
          That's not true. JTree has a TreeModel that has a TreeModelListener, and JList has a ListModel that has a ListDataListener.
          • 2. Re: Strange implemention for JComboBox.
            800268
            I think you mean "maintains" instead of "maintenance".

            As for an explanation, it was designed that way and that's the way it is now.

            For JComboBox, the selection model was made to extend the data model (ComboBoxModel extends ListModel, maybe because the selected data might not be in the data model)
            For JTree, the data model (TreeModel) and selection model (TreeSelectionModel) are separated.