This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

how to add value against each listview item  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys someone help me.
I am new in Javafx....my problem is i want to add integer value against each ListView item. How can i implement this? My code is given below

@FXML
ListView<String> lvDevice;

ObservableList<String> data = FXCollections.observableArrayList(
"test1", "test2", "test3", "test4", "test5");

@Override
public void start(Stage stage) {
lvDevice.setItems(data);
}

-------------------------------------
Now I want add integer value against each item say for test1-1, for test2-2 like that.....Please help me! Thanks.
 
Ranch Hand
Posts: 105
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if the FXCollections.replaceAll(...) method works for you.

Otherwise, I guess you could iterate the list, retrieve each data, change it and re-add it to the list.
 
Pallab Pal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please give me an example of using iterate
 
Vasilis Souvatzis
Ranch Hand
Posts: 105
1
Chrome Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's basically a for loop that goes through the List. I'm writing this out of my head but it should go this way:



Check your IDE for code completion but I'm fairly certain it goes similarly.
 
Ranch Hand
Posts: 374
24
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!