Java Reference
In-Depth Information
case "image":
albumCover.setImage((Image)value);
break;
}
}
If the handleMetadata method determines that the new metadata are of interest to the program, it sets the
metadata's value as either the string of a Label control or the Image of an ImageView node. Listing 9-9 shows the rest
of this application's code wherein these controls are created and placed into a GridPane for display to the user. There
have also been some minor additions to the media.css style sheet to set the size of the fonts used in the Label s. You
can view these changes in the source files for the AudioPlayer2 example application in the topic's example code.
Listing 9-9. Displaying the Metadata Information in the Scene Graph
public class AudioPlayer2 extends Application {
private Media media;
private MediaPlayer mediaPlayer;
private Label artist;
private Label album;
private Label title;
private Label year;
private ImageView albumCover;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
createControls();
createMedia();
final Scene scene = new Scene(createGridPane(), 800, 400);
final URL stylesheet = getClass().getResource("media.css");
scene.getStylesheets().add(stylesheet.toString());
primaryStage.setScene(scene);
primaryStage.setTitle("Audio Player 2");
primaryStage.show();
}
private GridPane createGridPane() {
final GridPane gp = new GridPane();
gp.setPadding(new Insets(10));
gp.setHgap(20);
gp.add(albumCover, 0, 0, 1, GridPane.REMAINING);
gp.add(title, 1, 0);
gp.add(artist, 1, 1);
gp.add(album, 1, 2);
gp.add(year, 1, 3);
 
Search WWH ::




Custom Search