I use the new released Java 8 version. I got a problem with the property bindings.
public class TouchTitle extends HBox{
private Label title;
private StringProperty fxBackgroundColor = new SimpleStringProperty("-fx-background-color: ");
public TouchTitle(TaskpaneFX taskpaneModel){
TouchTitleViewModel touchTitleViewModel = new TouchTitleViewModel(taskpaneModel);
title = new Label("");
title.textProperty().bind(touchTitleViewModel.titleTextProperty());
title.setStyle("-fx-font: "+ConfigurationConstants.FONT_SUB_HEADER+"");
title.setWrapText(true);
setPrefSize(Control.USE_COMPUTED_SIZE, Control.USE_COMPUTED_SIZE);
styleProperty().bind(fxBackgroundColor.concat(touchTitleViewModel.backgroundColorProperty()));
//Binding to the widthProperty, the property is from the taskpanemodel
minWidthProperty().bind(taskpaneModel.titleWidthProperty());
getStyleClass().add("taskpaneborder");
setAlignment(Pos.BOTTOM_LEFT);
getChildren().add(title);
}
}
public class TouchTaskPane extends Pane{
private TaskpaneFX taskpaneModel;
private TouchTaskPaneViewModel touchTaskPaneViewModel;
public TouchTaskPane(TaskpaneFX taskpaneModel, TouchViewModel touchViewModel, int index){
touchTaskPaneViewModel = new TouchTaskPaneViewModel(touchViewModel, taskpaneModel);
this.taskpaneModel = taskpaneModel;
setId(String.valueOf(index));
setMinSize(Control.USE_COMPUTED_SIZE, Control.USE_COMPUTED_SIZE);
getStyleClass().add("taskpaneborder");
initWidthPropertyListener();
initMouseClickedListener();
}
private void initWidthPropertyListener(){
minWidthProperty().bind(touchTaskPaneViewModel.taskpaneWidthPoperty());
maxWidthProperty().bind(touchTaskPaneViewModel.taskpaneWidthPoperty());
taskpaneModel.titleWidthProperty().bind(widthProperty());
}
private void initMouseClickedListener(){
setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
touchTaskPaneViewModel.handleTaskPaneSelected();
}
});
}
public int getTaskpaneId(){
return Integer.parseInt(this.getId());
}
}
So i want to keep the width of TouchTitle and TouchTaskPane equal. On the mouseclickedlistener, i set the width of the TouchTaskPane. With the width bindings i want, that the TouchTitle has the same width after the click. So the width of TouchTaskPane is binded to the property of the model. And the minWidthProperty is binded to the property of the model, too. So it should be synchronized automatically if the width is changed. On Java 7 with JavaFX 2.2 it works fine. But with Java 8, the width is only synchronized, if i click twice on the TouchTaskPane.
So it seems, the property is not refreshed after the first click.