Reputation: 1
I have a jList that was generated by NetBeans. I have declared a DefaultListModel but cannot link to up to the jList. My code is below and I have also tried using .setMethod.
DefaultListModel modeljLstShoppingCartName;
modeljLstShoppingCartName = new DefaultListModel();
jLstShoppingCartName = new JList(modeljLstShoppingCartName);
modeljLstShoppingCartName.addElement("Testing1");
The error I am receiving here is on the entire third line where it is saying:
incompatible types
required: java.awt.List
found: javax.swing.JList
I have imported:
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.DefaultListModel;
import javax.swing.JList;
Any help would be great as I've spent a few hours at this but with no success.
Upvotes: 0
Views: 1085
Reputation: 285405
Regarding:
incompatible types
required: java.awt.List
found: javax.swing.JList
This could be little more than a careless mistake. I'm betting that you have declared your jLstShoppingCartName variable as a java.awt.List variable not a javax.swing.JList variable.
Upvotes: 3