Java Reference
In-Depth Information
Listing 9-15. The GridPane Layout for the Player Controls
@Override
protected Node initView() {
final Button openButton = createOpenButton();
controlPanel = createControlPanel();
volumeSlider = createSlider("volumeSlider");
statusLabel = createLabel("Buffering", "statusDisplay");
positionSlider = createSlider("positionSlider");
totalDurationLabel = createLabel("00:00", "mediaText");
currentTimeLabel = createLabel("00:00", "mediaText");
final ImageView volLow = new ImageView();
volLow.setId("volumeLow");
final ImageView volHigh = new ImageView();
volHigh.setId("volumeHigh");
final GridPane gp = new GridPane();
gp.setHgap(1);
gp.setVgap(1);
gp.setPadding(new Insets(10));
final ColumnConstraints buttonCol = new ColumnConstraints(100);
final ColumnConstraints spacerCol = new ColumnConstraints(40, 80, 80);
final ColumnConstraints middleCol = new ColumnConstraints();
middleCol.setHgrow(Priority.ALWAYS);
gp.getColumnConstraints().addAll(buttonCol, spacerCol, middleCol,
spacerCol, buttonCol);
GridPane.setValignment(openButton, VPos.BOTTOM);
GridPane.setHalignment(volHigh, HPos.RIGHT);
GridPane.setValignment(volumeSlider, VPos.TOP);
GridPane.setHalignment(statusLabel, HPos.RIGHT);
GridPane.setValignment(statusLabel, VPos.TOP);
GridPane.setHalignment(currentTimeLabel, HPos.RIGHT);
gp.add(openButton, 0, 0, 1, 3);
gp.add(volLow, 1, 0);
gp.add(volHigh, 1, 0);
gp.add(volumeSlider, 1, 1);
gp.add(controlPanel, 2, 0, 1, 2);
gp.add(statusLabel, 3, 1);
gp.add(currentTimeLabel, 1, 2);
gp.add(positionSlider, 2, 2);
gp.add(totalDurationLabel, 3, 2);
return gp;
}
Search WWH ::




Custom Search