Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to add value against each listview item

 
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: 109
1
Netbeans IDE Chrome Java
  • 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: 109
1
Netbeans IDE Chrome Java
  • 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.
 
Rancher
Posts: 387
30
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic