-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicController.java
More file actions
92 lines (74 loc) · 1.97 KB
/
MusicController.java
File metadata and controls
92 lines (74 loc) · 1.97 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
/*
* MusicController
* This is the controller for the FXML document that contains the view.
*/
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class MusicController implements Initializable {
@FXML
private Button btnSearch;
@FXML
private TextField txtName;
@FXML
private Label lblName;
@FXML
private Label lblBorn;
@FXML
private Label lblDied;
@FXML
private Label lblCountry;
@FXML
private Label lblGenre;
@FXML
private Label lblWebsite;
@FXML
private Label lblLabel;
@FXML
private Label lblBio;
@FXML
private ImageView icon;
@FXML
private void handleButtonAction(ActionEvent e) {
// Create object to access the Model
MusicModel music = new MusicModel();
// Get artist name
String name = txtName.getText();
// Use the model to get the artist's information
if (!name.equals("") && music.getInfo(name))
{
lblName.setText(music.getName());
lblBorn.setText(music.getBornYear());
lblDied.setText(music.getDiedYear());
lblCountry.setText(music.getCountry());
lblGenre.setText(music.getGenre());
lblWebsite.setText(music.getWebsite());
lblLabel.setText(music.getLabel());
lblBio.setText(music.getBio());
icon.setImage(music.getImage());
}
else
{
lblName.setText("Artist not found!");
lblBorn.setText("");
lblDied.setText("");
lblCountry.setText("");
lblGenre.setText("");
lblWebsite.setText("");
lblLabel.setText("");
lblBio.setText("");
icon.setImage(new Image("badartistname.png"));
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}