Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package kontakty;
  7.  
  8. import java.net.URL;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. import java.util.ResourceBundle;
  12. import javafx.collections.FXCollections;
  13. import javafx.collections.ObservableList;
  14. import javafx.event.ActionEvent;
  15. import javafx.fxml.FXML;
  16. import javafx.fxml.Initializable;
  17. import javafx.scene.control.Label;
  18. import javafx.scene.control.ListView;
  19. import javafx.scene.control.TextField;
  20.  
  21. /**
  22. *
  23. * @author pweichbroth
  24. */
  25. public class FXMLDocumentController implements Initializable {
  26.  
  27. @FXML
  28. private ListView<String> lista;
  29. @FXML
  30. private TextField nowy;
  31.  
  32. private ObservableList<String> listaKontaktow;
  33.  
  34. @FXML
  35. private void handleButtonAction(ActionEvent event) {
  36. int i = lista.getSelectionModel().getSelectedIndex();
  37. listaKontaktow.remove(i);
  38. }
  39.  
  40. @FXML
  41. private void addAction(ActionEvent event) {
  42. String nowyElement = nowy.getText();
  43. listaKontaktow.add(nowyElement);
  44. }
  45.  
  46. @Override
  47. public void initialize(URL url, ResourceBundle rb) {
  48. List<String> arrayList = new ArrayList<>();
  49. arrayList.add("Alicja 896523147");
  50. arrayList.add("Daria 123456789");
  51. arrayList.add("Piotr 154829047");
  52. arrayList.add("Dariusz 256987415");
  53. listaKontaktow = FXCollections.observableArrayList(arrayList);
  54. lista.setItems(listaKontaktow);
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement