Java JComboBox Incompatible Types: Cannot be converted to string

前端 未结 1 1239
悲哀的现实
悲哀的现实 2021-01-27 09:43

I have this error when i try to add items in the JComboBox

incompatible types: ComboBox cannot be converted to String

This is my met

1条回答
  •  再見小時候
    2021-01-27 10:22

    It is hard to be certain without knowing how combobox is declared and at which line the Exception is being thrown...

    My guess: combobox is declared as a JComboBox that takes a String and you the Exception is being thrown since a ComboBox is being added instead of a String.

    Possible correction: declare the JComboBox to hold instances of ComboBox:

    private JComboBox combobox;
    

    0 讨论(0)
提交回复
热议问题