Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Table Column to Array for JList

807601Jun 9 2008 — edited Jun 11 2008
I would post my code here.. but I've tried so many different approaches to this that I wouldn't even know where to begin to post.

Here's what I'm looking for, and I'm sure it's something easy for the awesomely skilled programmers who view this forum

I need to take a column from a database and turn it into an array to be used in a JList.

I managed to create a ArrayList but I can't convert an array list to an array to be used in the JList. (I've tried numerous times and it just won't work)

I imagine doing the database pull the proper way (into an array to begin with) would be the best approach... but I'm lost on that one as well. (I've been working on this project non stop since friday night)

one last question... Isn't there a way to make sure at least one item on a JList is checked at all times??? Am I totally missing the boat with the method for this? Combo Boxes have it, I wouldn't see why JList wouldn't ( I need it to prevent a nullpointer)

Thanks Again! (and thanks to the folks who insisted I switch from a flat file to a database.. it took me the weekend to figure out the coding, but I'm glad I took the time to figure it out)

String[] test = (String[]) dl.retrieveMovieNames().toArray(

new String[dl.retrieveMovieNames().size()]);



Exception in thread "main" java.lang.ArrayStoreException

at java.lang.System.arraycopy(Native Method)

at java.util.ArrayList.toArray(ArrayList.java:306)

at UserInterface.buildQueryPanel(UserInterface.java:204)

at UserInterface.<init>(UserInterface.java:63)

at UserInterface.main(UserInterface.java:581)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 9 2008
Added on Jun 9 2008
15 comments
521 views