views:

29

answers:

2

My current application uses a JList and everything is well (the only customization I did was to set the italic font on some of the rows).

Now I want to "upgrade" the user interface and instead of just labels in the List, I want a checkbox and a text field to be able to update the entry.

I started changing the code and adding a custom cell renderer and a custom cell model. My current problem is that the JPanel that the cell renderer is returning is not using the whole width of the container, so several list items are actually shown on the same line.

But now, I am wondering whether I should just change the whole thing to use JTable. I still need to add / remove items in the list though...

Any suggestion which one is better ? and if going with the JList, how should I go about fixing my current problem ?

+1  A: 

In my experience using JTable is usually easier as it allows more complex data and functionality out-of-the-box. Usually when I try to do something the JList can't do, I just switch to JTable without a second thought. What you want sounds like something that should be pretty trivial to implement in a table. I suggest you try it out with some mock data to see if you can make it look and work the way you like (especially in case you want it to look like a list).

Carlos
Thanks for the advice, let's see if I can quickly fix with the JList and if not, I'll switch over.
Matthieu
Lot of work ahead, but I hope for the better...
Matthieu
A: 

Try calling setLayoutOrientation(JList.VERTICAL) on your JList. That will restrict JList to a single column.

Devon_C_Miller
I will try that...
Matthieu
No, that did not help... looks like I am going to move to JTables... hopefully will make things a bit easier...
Matthieu