-
Bug
-
Resolution: Unresolved
-
P3
-
11, 17, 18, 19
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Windows 10, OpenJDK 17.0.2
A DESCRIPTION OF THE PROBLEM :
On Windows, the value of Insets is not calculated correctly when changing the default display.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Changing the default display
After, execute command
java --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED -cp bin M
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
- Case 1 - : Correct
Default:\Display0
\Display0
java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=78,bottom=0,right=0]
\Display1
java.awt.Rectangle[x=1920,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=0,bottom=0,right=62]
0: java.awt.Insets[top=0,left=78,bottom=0,right=0]
1: java.awt.Insets[top=0,left=0,bottom=0,right=62]
- Case 2 - : Not correct
Default:\Display1
\Display0
java.awt.Rectangle[x=-1920,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=78,bottom=0,right=0]
\Display1
java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=78,bottom=0,right=0]
0: java.awt.Insets[top=0,left=78,bottom=0,right=0]
1: java.awt.Insets[top=0,left=78,bottom=0,right=0]
ACTUAL -
Case 2
1: java.awt.Insets[top=0,left=0,bottom=0,right=62]
---------- BEGIN SOURCE ----------
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.lang.reflect.Method;
public class M {
public static void main(String[] args) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
System.out.println("Default:" + ge.getDefaultScreenDevice().getIDstring());
for(GraphicsDevice gd : ge.getScreenDevices()) {
GraphicsConfiguration gc = gd.getDefaultConfiguration();
System.out.println(gd.getIDstring());
System.out.println(" " + gc.getBounds());
System.out.println(" " + toolkit.getScreenInsets(gc));
}
try {
Method m = toolkit.getClass().getDeclaredMethod("getScreenInsets", int.class);
m.setAccessible(true);
System.out.println("0: " + m.invoke(toolkit, 0));
System.out.println("1: " + m.invoke(toolkit, 1));
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 10, OpenJDK 17.0.2
A DESCRIPTION OF THE PROBLEM :
On Windows, the value of Insets is not calculated correctly when changing the default display.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Changing the default display
After, execute command
java --add-exports java.desktop/sun.awt.windows=ALL-UNNAMED --add-opens java.desktop/sun.awt.windows=ALL-UNNAMED -cp bin M
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
- Case 1 - : Correct
Default:\Display0
\Display0
java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=78,bottom=0,right=0]
\Display1
java.awt.Rectangle[x=1920,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=0,bottom=0,right=62]
0: java.awt.Insets[top=0,left=78,bottom=0,right=0]
1: java.awt.Insets[top=0,left=0,bottom=0,right=62]
- Case 2 - : Not correct
Default:\Display1
\Display0
java.awt.Rectangle[x=-1920,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=78,bottom=0,right=0]
\Display1
java.awt.Rectangle[x=0,y=0,width=1920,height=1080]
java.awt.Insets[top=0,left=78,bottom=0,right=0]
0: java.awt.Insets[top=0,left=78,bottom=0,right=0]
1: java.awt.Insets[top=0,left=78,bottom=0,right=0]
ACTUAL -
Case 2
1: java.awt.Insets[top=0,left=0,bottom=0,right=62]
---------- BEGIN SOURCE ----------
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.lang.reflect.Method;
public class M {
public static void main(String[] args) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
System.out.println("Default:" + ge.getDefaultScreenDevice().getIDstring());
for(GraphicsDevice gd : ge.getScreenDevices()) {
GraphicsConfiguration gc = gd.getDefaultConfiguration();
System.out.println(gd.getIDstring());
System.out.println(" " + gc.getBounds());
System.out.println(" " + toolkit.getScreenInsets(gc));
}
try {
Method m = toolkit.getClass().getDeclaredMethod("getScreenInsets", int.class);
m.setAccessible(true);
System.out.println("0: " + m.invoke(toolkit, 0));
System.out.println("1: " + m.invoke(toolkit, 1));
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
---------- END SOURCE ----------
FREQUENCY : always