Re: Saving and Opening an Array List



Hey Bjorn and Steve,

I still cant get the reading from array to text field working.

I looked through the book I have (Bell & PArr Java for Students) and I
found this piece of code which should've got it working.

---------
private void cut() {
if (itemSelected)
text = (String)artists.get(indexSelected); //This last piece of
code is what the book gave me
--------------

And my program compiles, but when i run it and do the action that uses the
cut method i get a "java.lang.ClassCastException" thrown at me.

I've breifly covered exception, but I haven't come across this before and
cant even figure out what it could mean.
It refers to the code that i got from the book (think it means the String
part)

This isn't related to the Book program I'm trying to do, this is to do
with a little class exercise that I'm trying to develop further so my end
project can be better.

Any ideas?

Here are some notes on my code;

So you know 'text' is a String I declared that gets text from the
TextField. I've also used it here for example;
-----
artist = new Artist(text);
artists.add(artist);
-----
That adds a new 'Artist'(Artist is a class, not the main one. It has a
constructor in it which creates an 'artist', well the visual aspects of it
at least.) to the array list 'artists'.

Can you help me out a little more?


.