Thursday, 14 February 2008

Vectors and ListModels

For the last few days I've been trying to show the library of schemas and the current active schemas in jLists on the GUI. Each list of schemas is currently stored in a public Vector in the Const class, so accessing and displaying them from the GUI should be easy.

That seems to be only partly correct...

Accessing the Vector is fine, but displaying it in the jList is causing a major problem. I think the problem is caused by using passing the Vector directly to the jList constructer. This is allowed, but doesn't seem to take into account changes to the Vector itself. The solution looks like defining a ListModel, and making changes to that rather than the Vector. The problem with this is that apart from writing my own ListModel class, there doesn't seem to be a way to use a Vector to create a ListModel.

After spending a few days on this, I'm starting to consider just writing my own ListModel. Hopefully this will be simple enough, although I'd rather use a tested solution than hack together a link between such important components.

No comments: