我使用java 8u162和NVidia GPU(以及最新的驱动程序)在Red Hat 6.8 x64上使用2个全高清屏幕在Linux上开发javaFX应用程序。
我在检索物理屏幕数量方面遇到了问题:
我将JavaFX API与AWT API进行了比较:
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice [] gdev = env.getScreenDevices();
AWT在两种配置模式下都会返回2个屏幕设备。
我还使用ubuntu x64机器检查了java 9和java 10,并且遇到了与JavaFX相同的问题。
我试过调试这个问题似乎是本地代码中的libglass.so问题。
您如何看待这个?我错过了什么吗?
这是重现问题的代码:
public class ScreenTest extends Application {
private static final int SIZE = 1600;
private final AnchorPane root = new AnchorPane();
@Override
public void start(Stage primaryStage) throws Exception {
root.backgroundProperty().set(new Background(new BackgroundFill(Color.BEIGE, null, null)));
Scene scene = new Scene(root, SIZE, SIZE);
primaryStage.show();
Screen.getScreens().forEach(screen -> System.out.println("JAVAFX :"+ screen));
GraphicsEnvironment env =GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gdev = env.getScreenDevices();
for (GraphicsDevice d : gdev) {
System.out.println("AWT:" + d);
}
}
public static void main(String... strings) {
launch(strings);
}
}
这是我的xorg.conf X11配置:
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
EndSection
Section "Files"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "CMN"
HorizSync 53.0 - 66.0
VertRefresh 48.0 - 60.0
Option "DPMS"
EndSection
Section "Monitor"
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL C7017T"
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 76.0
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro K3100M"
BusID "PCI:1:0:0"
Screen 0
EndSection
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "Quadro K3100M"
BusID "PCI:1:0:0"
Screen 1
EndSection