我試圖調整一些窗格的大小,如果一個元素有LayoutX < 0. 我已經創建了一個存儲偏移量來調整大小的DoubeProperty。節點沒有調整大小
監聽器是這樣的:
offset.addListener((observable, oldValue, newValue) -> {
if(newValue.doubleValue() > 0) {
setPrefWidth(getWidth() + newValue.doubleValue());
}
});
但TE節點沒有; T改變他的財產。當我點擊元素時,我看到偏移量比0更多。我如何強制調整大小?
我也想用綁定:
prefWidthProperty().bind(Bindings.when(Bindings.isNotEmpty(children))
.then(Bindings.when(offset.greaterThan(0))
.then(widthProperty().add(offset))
.otherwise(widthProperty()))
.otherwise(MINIMAL_RELATION_WIDTH)
);
但相同的結果。奇怪的是,如果我添加一個事件懸停到其他元素(例如陰影),改變BoundsInLocalProperty ..我看到,調整大小執行afet懸停在元素上。我不明白爲什麼