Guest User

Untitled

a guest
May 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. material_comboBox_type.getItems().addAll(types);
  2.  
  3. material_comboBox_type.setCellFactory((ListView<SimpleTableObject>
  4. param) -> {
  5. final ListCell<SimpleTableObject> cell = new
  6. ListCell<SimpleTableObject>() {
  7. @Override
  8. public void updateItem(SimpleTableObject item, boolean empty) {
  9. super.updateItem(item, empty);
  10. if (item != null) {
  11.  
  12. setText(item.getName().get());//return String, actuall name of material
  13.  
  14. }
  15. else {
  16. setText(null);
  17. }
  18. }
  19. };
  20. return cell;
  21. });
  22.  
  23. private static class SimpleTableObjectListCell extends ListCell<SimpleTableObject> {
  24.  
  25. @Override
  26. public void updateItem(SimpleTableObject item, boolean empty) {
  27. super.updateItem(item, empty);
  28. if (item != null) {
  29.  
  30. setText(item.getName().get());//return String, actuall name of material
  31.  
  32. }
  33. else {
  34. setText(null);
  35. }
  36. }
  37.  
  38. }
  39.  
  40. materialComboBoxType.setCellFactory(listView -> new SimpleTableObjectListCell());
  41. materialComboBoxType.setButtonCell(new SimpleTableObjectListCell());
  42.  
  43. material_comboBox_type.setConverter(new StringConverter<SimpleTableObject>() {
  44. @Override
  45. public String toString(SimpleTableObject object) {
  46. return object.getName().get();
  47. }
  48.  
  49. @Override
  50. public SimpleTableObject fromString(String string) {
  51. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  52. }
  53. });
Add Comment
Please, Sign In to add comment