Skip to content
Snippets Groups Projects
Commit d7ed8301 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

Merge branch '20-hurl-selected-thoughts' into 'master'

Resolve "hurl selected thoughts"

Closes #20

See merge request !24
parents 0468d1f6 5180a22c
No related branches found
No related tags found
1 merge request!24Resolve "hurl selected thoughts"
package sample;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
......@@ -25,11 +26,17 @@ public class Controller {
//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() {
ObservableList<Integer> indices = listView.getSelectionModel().getSelectedIndices();
for (int i = indices.size()-1; i >= 0; i--)
listView.getItems().remove((int) indices.get(i));
}
}
......@@ -16,6 +16,6 @@
<Font size="17.0" />
</font></Text>
<Button layoutX="531.0" layoutY="10.0" mnemonicParsing="false" onAction="#handleHurlAll" text="Hurl all your thoughts" />
<ListView fx:id="listView" layoutX="40.0" layoutY="52.0" prefHeight="236.0" prefWidth="585.0" style="-fx-border-color: #ce94a2; -fx-background-color: #f3f4f5; -fx-border-width: 1px;" />
<Button layoutX="365.0" layoutY="10.0" mnemonicParsing="false" onAction="#handleHurlSelected" text="Hurl selected thoughts" />
</children>
</AnchorPane>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment