Results 1 to 7 of 7
- 09-06-2009, 04:10 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Strange, 'Cannot find symbol' error
Java Experts,
I have added a JList to the GUI of my application. When running the project I received the error, 'Cannot find symbol' with, 'setListData' underlined. here's the code:
private void displayGroup()
{
Collection<Team> teams = football.getTeams();
teamList4.setListData(teams);
teamList4.setSelectedIndex(0);
}
I have followed an example from a textbook, so I'm curious what error has been made here.
Please help.
-
Look up in the API what JList#setListData takes for its parameter. According to the API that I've just looked at, there are two possible choices here, but Collection is not one of them.
- 09-06-2009, 04:32 PM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
setListData intake array or vector, not collection, vector implements collection, but collection is not vector
- 09-06-2009, 04:39 PM #4
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Hi,
I have looked at the autocomplete for the JList which shows:
setListData(Object[])
setListData(Vector[])
I thought Object was a generic type which could accept any variable type?
-
That's not Object, that says Object[], and that's a big difference. It will accept an array of any object, but Collection<...> is not an array.
- 09-06-2009, 04:47 PM #6
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Thanks, just realised this.
Could you advise how I can convert my Collection to an object array.
- 09-06-2009, 04:54 PM #7
Member
- Join Date
- Sep 2009
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
'Cannot find symbol' error
By minihazard10 in forum New To JavaReplies: 6Last Post: 10-10-2008, 04:05 AM -
cannot find symbol class error
By po0oker in forum New To JavaReplies: 5Last Post: 10-31-2007, 02:52 PM -
Error: cannot find symbol
By silvia in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:39 AM -
Error: cannot find symbol
By cachi in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 08:12 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks