• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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: 103
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: 103
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!