Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Count items in JList

 
yesaya handoyo
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,i want to ask how to count items in the JList..Thanks a lot..
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JList is not aware of the actual data.
As with all components following MVC, there is a model associated with the JList which holds the data.

So what you need to do is get the model from the JList and then query it for the item count.
 
yesaya handoyo
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get from the forums.sun.com like this..
int size = list.getModel().getSize();
What do you think??Thanks a lot..
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by yesaya handoyo:
I get from the forums.sun.com like this..
int size = list.getModel().getSize();
What do you think??Thanks a lot..


The real question is what do you think?
Is this different from what I said?

Did you try it out?
Did you get any results?
Are they correct?

Also please do take out time to read this important information
 
yesaya handoyo
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've not tried it out..
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you get if you do?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic