• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Warning: The expression of type AbstractListModel needs conversion to conform to ListModel<String>

 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to solve this compiler warning but can't figure out how. I think that I know why and its because the AbstractListModel that I extend can accept any type and the ListModel is of the String type. I can't develop a solution, highly confused on how to solve efficiently and need some more experienced help/teaching.


This is the JList and ListModel declaration


Also my list doesn't show on the graphical user interface because of the JList<String> declaration and if I remove it, the list shows but throws another compiler warning: raw type should be parameterized, in addition to the compilar warning above.


This is the AbstractListModel class.


I have tried doing extends AbstractListModel<String> and it removes the compiler conversion warning but it shows a compiler error for the overridden method getElementAt(int index) because it returns an Object instead of a String.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're halfway there, I think. Having getElementAt() return String, as ListModel requires, should be the other half.
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:You're halfway there, I think. Having getElementAt() return String, as ListModel requires, should be the other half.



Thank You Paul, that did the trick. I actually switched from using a String to a data object and then just used the data object as the type. You have to love objects :)
 
reply
    Bookmark Topic Watch Topic
  • New Topic