This repository was archived by the owner on May 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeResourcePicController.java
More file actions
101 lines (85 loc) · 2.56 KB
/
ChangeResourcePicController.java
File metadata and controls
101 lines (85 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.MenuBar;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import javafx.fxml.Initializable;
/**
* This class handles events when certain parts of the scene is interacted and outputs image data.
* @author Kevin Pan 969449
* @version 1
*/
public class ChangeResourcePicController implements Initializable{
@FXML
ObservableList<String> pictures = FXCollections.observableArrayList("Picture 1","Picture 2","Picture 3");
@FXML
private String selected;
@FXML
private Button save;
@FXML
private ChoiceBox<String> pic;
@FXML
private Label username;
@FXML
private ImageView picture;
@FXML
private Image image;
@FXML
/**
* Displays different images depending on which choice is selected.
* @param event The event is when the button is clicked.
* @throws IOException Exception to combat failed or interrupted inputs.
*/
public void handlePicturePushed(ActionEvent event) throws IOException{
selected = pic.getSelectionModel().getSelectedItem();
if(selected == "Picture 1") {
image = new Image("cd-dvd.jpg");
picture.setImage(image);
}
else if (selected == "Picture 2") {
image = new Image("laptop.jpg");
picture.setImage(image);
}
else if (selected == "Picture 3") {
image = new Image("book.png");
picture.setImage(image);
}
}
@FXML
/**
* Saves the selected picture and closes the window.
* @param event The event is when the button is clicked.
* @throws IOException Exception to combat failed or interrupted inputs.
*/
public void handleSave(ActionEvent event){
Stage stage = (Stage) save.getScene().getWindow();
stage.close();
}
@Override
/**
* Saves the selected avatar and closes the window.
* @param event The event is when the button is clicked.
* @throws IOException Exception to combat failed or interrupted inputs.
*/
public void initialize(URL url, ResourceBundle resources) {
System.out.println("Working...");
pic.setValue("Picture 1");
pic.setItems(pictures);
}
}