Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package kontakty;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.ResourceBundle;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.fxml.Initializable;
- import javafx.scene.control.Label;
- import javafx.scene.control.ListView;
- import javafx.scene.control.TextField;
- /**
- *
- * @author pweichbroth
- */
- public class FXMLDocumentController implements Initializable {
- @FXML
- private ListView<String> lista;
- @FXML
- private TextField nowy;
- private ObservableList<String> listaKontaktow;
- @FXML
- private void handleButtonAction(ActionEvent event) {
- int i = lista.getSelectionModel().getSelectedIndex();
- listaKontaktow.remove(i);
- }
- @FXML
- private void addAction(ActionEvent event) {
- String nowyElement = nowy.getText();
- listaKontaktow.add(nowyElement);
- }
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- List<String> arrayList = new ArrayList<>();
- arrayList.add("Alicja 896523147");
- arrayList.add("Daria 123456789");
- arrayList.add("Piotr 154829047");
- arrayList.add("Dariusz 256987415");
- listaKontaktow = FXCollections.observableArrayList(arrayList);
- lista.setItems(listaKontaktow);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement