我正在使用MedusaFX庫來獲取我正在處理的項目的測量儀。我正在使用JavaFX應用程序來運行所有內容,使用Scene Builder創建FXML文件以創建佈局。我觀察到的是,如果我做陣列中的MedusaFX元素,如果編輯陣列,請勿更新屏幕
@FXML private Gauge gauge1 = new Gauge();
gauge1.setValue(30);
然後,gauge1變量得到正確的值集。但是,如果我做
@FXML private Gauge gauge1 = new Gauge();
ArrayList<Gauge> list = new ArrayList<>();
list.add(gauge1);
list.get(0).setValue(30);
System.out.println(gauge1);
System.out.println(list.get(0));
我的輸出
{"title":"Temperature","subTitle":"Temperature","unit":"°F","value":0.0,"minValue":0.0,"maxValue":175.0,"threshold":60.0,"minMeasuredValue":0.0,"maxMeasuredValue":0.0}
{"title":"","subTitle":"","unit":"","value":30.0,"minValue":0.0,"maxValue":100.0,"threshold":100.0,"minMeasuredValue":30.0,"maxMeasuredValue":30.0}
這個輸出讓我困惑,因爲它看起來像ArrayList中創建計的新實例,而不是修改它其中的一個。有什麼建議麼?