There are lines of code:

private JList jlResultsList; 

And in the constructor:

 jlResultsList = new JList(arraySearchResult); jlResultsList.setSelectionModel(ListSelectionModel.SINGLE_SELECTION); 

IDE notes as a ListSelectionModel.SINGLE_SELECTION error.

And when trying to compile gives:

Error: (49, 59) java: incompatible types: int cannot be converted to javax.swing.ListSelectionModel

import javax.swing.*; it is registered. What could be the error?

    1 answer 1

    It should be like this:

     jlResultsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 

    The setSelectionMode method takes an int value, one of the three:

    • ListSelectionModel.SINGLE_SELECTION
    • ListSelectionModel.SINGLE_INTERVAL_SELECTION
    • ListSelectionModel.MULTIPLE_INTERVAL_SELECTION

    While the setSelectionModel method takes a ListSelectionModel . Since it is incorrect to send an int instead of a ListSelectionModel , an error occurs.