-
Bug
-
Resolution: Incomplete
-
P4
-
None
-
11.0.3
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Windows 10, Version 1607, OS Build 14393.3085
OpenJDK Version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
two monitors, left with no scaling, right with scaling
A DESCRIPTION OF THE PROBLEM :
Running on Windows 10. I have two monitors. Left monitor has 100% scaling (aka "no scaling"). Right monitor is a 4K monitor with 150% scaling. Run swing application. On left monitor, JOptionPane dialog popups appear in the expected place (centered over frame). Drag application to right monitor. JOptionPane dialog popups appear in the wrong place (not centered over frame, not sized well).
The important thing here is: the scaling must be different on the two monitors.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set left monitor to 100% scaling. Set right monitor to 150% scaling. Run provided application. Drag application to left monitor and press the "Show Popup" button. Popup appears centered over JFrame. Drag application to right monitor and press the "Show Popup" button. Popup appears off to the left of the JFrame and is not sized well.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Popup on the right monitor should be centered over the JFrame.
ACTUAL -
Popup on the right monitor appears off to the left and is badly shaped.
---------- BEGIN SOURCE ----------
package com.andrewgotte.ui;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import sun.awt.Win32GraphicsDevice;
public class Java11Bug {
public static final void main(String...strings) {
StringBuilder sb = new StringBuilder();
try {
sb.append("YOU NEED AT LEAST TWO SCREENS TO REPRODUCE THE ISSUE.").append('\n');
sb.append('\n');
sb.append("IN WINDOWS DISPLAY SETTINGS :\n");
sb.append(" 1) SET LEFT SCREEN TO 100% scale\n");
sb.append(" 2) SET RIGHT SCREEN TO 150% scale\n");
sb.append('\n');
sb.append("Verifying your environment...\n");
sb.append('\n');
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gdarray = ge.getScreenDevices();
sb.append("Number of screens detected: ").append(gdarray.length).append('\n');
for ( int i=0; i<gdarray.length; ++i ) {
sb.append('\n');
sb.append("Screen #").append(i+1).append(":\n");
GraphicsDevice gd = gdarray[i];
if ( gd instanceof Win32GraphicsDevice ) {
Win32GraphicsDevice wgd = (Win32GraphicsDevice)gd;
GraphicsConfiguration gc = wgd.getDefaultConfiguration();
Rectangle r = gc.getBounds();
sb.append(" x = ").append(r.x).append("\n");
sb.append(" y = ").append(r.y).append("\n");
sb.append(" width = ").append(r.width).append("\n");
sb.append(" height = ").append(r.height).append("\n");
sb.append(" scaleX = ").append(wgd.getDefaultScaleX()).append("\n");
sb.append(" scaleY = ").append(wgd.getDefaultScaleY()).append("\n");
}
else {
sb.append(" Not Windows ?\n");
}
}
sb.append('\n');
sb.append("Move application to screen 1 and click button below. Popup appears centered over application.\n");
sb.append('\n');
sb.append("Move application to screen 2 and click button below. Popup does not appear centered over application.\n");
}
catch ( Exception e ) {
sb.append("An error occurred while trying to verify your environment,\nbut you may still be able to demonstrate the bug");
}
JFrame frame = new JFrame();
JTextPane textPane = new JTextPane();
textPane.setText(sb.toString());
JScrollPane scrollPane = new JScrollPane(textPane);
JButton showPopup = new JButton("Show Popup");
showPopup.addActionListener((e) -> {
JOptionPane.showMessageDialog(frame, "This should appear directly over main frame.");
});
JPanel buttonPanel = new JPanel();
buttonPanel.add(showPopup);
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
JPanel panel = new JPanel(new BorderLayout());
panel.add(scrollPane, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.SOUTH);
panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setBounds(0, 0, 500, 650);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround at this time.
FREQUENCY : always
Windows 10, Version 1607, OS Build 14393.3085
OpenJDK Version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
two monitors, left with no scaling, right with scaling
A DESCRIPTION OF THE PROBLEM :
Running on Windows 10. I have two monitors. Left monitor has 100% scaling (aka "no scaling"). Right monitor is a 4K monitor with 150% scaling. Run swing application. On left monitor, JOptionPane dialog popups appear in the expected place (centered over frame). Drag application to right monitor. JOptionPane dialog popups appear in the wrong place (not centered over frame, not sized well).
The important thing here is: the scaling must be different on the two monitors.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set left monitor to 100% scaling. Set right monitor to 150% scaling. Run provided application. Drag application to left monitor and press the "Show Popup" button. Popup appears centered over JFrame. Drag application to right monitor and press the "Show Popup" button. Popup appears off to the left of the JFrame and is not sized well.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Popup on the right monitor should be centered over the JFrame.
ACTUAL -
Popup on the right monitor appears off to the left and is badly shaped.
---------- BEGIN SOURCE ----------
package com.andrewgotte.ui;
import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import sun.awt.Win32GraphicsDevice;
public class Java11Bug {
public static final void main(String...strings) {
StringBuilder sb = new StringBuilder();
try {
sb.append("YOU NEED AT LEAST TWO SCREENS TO REPRODUCE THE ISSUE.").append('\n');
sb.append('\n');
sb.append("IN WINDOWS DISPLAY SETTINGS :\n");
sb.append(" 1) SET LEFT SCREEN TO 100% scale\n");
sb.append(" 2) SET RIGHT SCREEN TO 150% scale\n");
sb.append('\n');
sb.append("Verifying your environment...\n");
sb.append('\n');
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gdarray = ge.getScreenDevices();
sb.append("Number of screens detected: ").append(gdarray.length).append('\n');
for ( int i=0; i<gdarray.length; ++i ) {
sb.append('\n');
sb.append("Screen #").append(i+1).append(":\n");
GraphicsDevice gd = gdarray[i];
if ( gd instanceof Win32GraphicsDevice ) {
Win32GraphicsDevice wgd = (Win32GraphicsDevice)gd;
GraphicsConfiguration gc = wgd.getDefaultConfiguration();
Rectangle r = gc.getBounds();
sb.append(" x = ").append(r.x).append("\n");
sb.append(" y = ").append(r.y).append("\n");
sb.append(" width = ").append(r.width).append("\n");
sb.append(" height = ").append(r.height).append("\n");
sb.append(" scaleX = ").append(wgd.getDefaultScaleX()).append("\n");
sb.append(" scaleY = ").append(wgd.getDefaultScaleY()).append("\n");
}
else {
sb.append(" Not Windows ?\n");
}
}
sb.append('\n');
sb.append("Move application to screen 1 and click button below. Popup appears centered over application.\n");
sb.append('\n');
sb.append("Move application to screen 2 and click button below. Popup does not appear centered over application.\n");
}
catch ( Exception e ) {
sb.append("An error occurred while trying to verify your environment,\nbut you may still be able to demonstrate the bug");
}
JFrame frame = new JFrame();
JTextPane textPane = new JTextPane();
textPane.setText(sb.toString());
JScrollPane scrollPane = new JScrollPane(textPane);
JButton showPopup = new JButton("Show Popup");
showPopup.addActionListener((e) -> {
JOptionPane.showMessageDialog(frame, "This should appear directly over main frame.");
});
JPanel buttonPanel = new JPanel();
buttonPanel.add(showPopup);
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
JPanel panel = new JPanel(new BorderLayout());
panel.add(scrollPane, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.SOUTH);
panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setBounds(0, 0, 500, 650);
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround at this time.
FREQUENCY : always