Skip to content
Snippets Groups Projects
Controller.java 985 B
Newer Older
  • Learn to ignore specific revisions
  • package sample;
    
    
    import javafx.event.ActionEvent;
    
    import javafx.fxml.FXML;
    
    import javafx.scene.control.ListView;
    import javafx.scene.control.SelectionMode;
    
    import javafx.scene.control.TextArea;
    
    
    public class Controller {
    
    
        @FXML
        private TextArea textArea;
    
    
        @FXML
        private ListView<String> listView;
    
    
        @FXML
        private void handleSubmit() {
    
    
    Herman Andersen Dyrkorn's avatar
    Herman Andersen Dyrkorn committed
            //create new thought, parameter from textArea
            Thought t = new Thought(textArea.getText());
    
            //clear textArea
            textArea.clear();
    
    
            //add the thoughts to the lists
            listView.getItems().addAll(t.getThought());
            listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    
        }
    
        public void handleHurlAll() {
            //delete all thoughts and display the list
    
            listView.getItems().clear();
    
    
        public void handleHurlSelected() {
            int index = listView.getSelectionModel().getSelectedIndex();
            listView.getItems().remove(index);
        }