-
Bug
-
Resolution: Fixed
-
P3
-
jfx11, 8, jfx15, jfx16
-
generic
-
generic
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8256708 | 8u291 | Kevin Rushforth | P3 | Resolved | Fixed | b02 |
ADDITIONAL SYSTEM INFORMATION :
Win8.1, JDK12, JavaFX 16ea+1
A DESCRIPTION OF THE PROBLEM :
This issue has always existed as far as I know and exists on the latest JavaFX 16ea+1.
Because the private method `javafx.stage.Screen.updateConfiguration`
uses
```
Screen.screens.clear();
Screen.screens.addAll(newScreens);
```
instead of
```
Screen.screens.setAll(newScreens);
```
changes in the list produce 2 change events, resulting in an invalid intermediate state (empty list after `clear()`). Even worse, list of screens can be empty, provided there is no screen available.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Plug/unplug screen from the system
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Single list change when screen is pluged/unplugged.
ACTUAL -
Multiple list changes when screen is plugged/unplugged.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.collections.ListChangeListener.Change;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Screen;
import javafx.stage.Stage;
class ScreenEvents extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Screen.getScreens().addListener((Change<?> event) -> {
System.out.println("");
System.out.println(Screen.getPrimary());
System.out.println(Screen.getScreens().size());
});
final StackPane background = new StackPane(); final Scene scene = new Scene(background, 600, 500);
stage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Ignore every second list change event
FREQUENCY : always
Win8.1, JDK12, JavaFX 16ea+1
A DESCRIPTION OF THE PROBLEM :
This issue has always existed as far as I know and exists on the latest JavaFX 16ea+1.
Because the private method `javafx.stage.Screen.updateConfiguration`
uses
```
Screen.screens.clear();
Screen.screens.addAll(newScreens);
```
instead of
```
Screen.screens.setAll(newScreens);
```
changes in the list produce 2 change events, resulting in an invalid intermediate state (empty list after `clear()`). Even worse, list of screens can be empty, provided there is no screen available.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Plug/unplug screen from the system
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Single list change when screen is pluged/unplugged.
ACTUAL -
Multiple list changes when screen is plugged/unplugged.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.collections.ListChangeListener.Change;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Screen;
import javafx.stage.Stage;
class ScreenEvents extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Screen.getScreens().addListener((Change<?> event) -> {
System.out.println("");
System.out.println(Screen.getPrimary());
System.out.println(Screen.getScreens().size());
});
final StackPane background = new StackPane(); final Scene scene = new Scene(background, 600, 500);
stage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Ignore every second list change event
FREQUENCY : always
- backported by
-
JDK-8256708 Screen.getScreens() is empty sometimes
- Resolved