-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect combobox popup menu offset at north side #630
Comments
I tracked down the issue, it appeared on Java 9+ because this method in /**
* Calculate the placement and size of the popup portion of the combo box based
* on the combo box location and the enclosing screen bounds. If
* no transformations are required, then the returned rectangle will
* have the same values as the parameters.
*
* @param px starting x location
* @param py starting y location
* @param pw starting width
* @param ph starting height
* @return a rectangle which represents the placement and size of the popup
*/
protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds;
// Calculate the desktop dimensions relative to the combo box.
GraphicsConfiguration gc = comboBox.getGraphicsConfiguration();
Point p = new Point();
SwingUtilities.convertPointFromScreen(p, comboBox);
if (gc != null) {
Insets screenInsets = toolkit.getScreenInsets(gc);
screenBounds = gc.getBounds();
screenBounds.width -= (screenInsets.left + screenInsets.right);
screenBounds.height -= (screenInsets.top + screenInsets.bottom);
screenBounds.x += (p.x + screenInsets.left);
screenBounds.y += (p.y + screenInsets.top);
}
else {
screenBounds = new Rectangle(p, toolkit.getScreenSize());
}
int borderHeight = 0;
Border popupBorder = getBorder();
if (popupBorder != null) {
Insets borderInsets = popupBorder.getBorderInsets(this);
borderHeight = borderInsets.top + borderInsets.bottom;
screenBounds.width -= (borderInsets.left + borderInsets.right);
screenBounds.height -= borderHeight;
}
Rectangle rect = new Rectangle(px, py, pw, ph);
if (py + ph > screenBounds.y + screenBounds.height) {
if (ph <= -screenBounds.y - borderHeight) {
// popup goes above
rect.y = -ph - borderHeight;
} else {
// a full screen height popup
rect.y = screenBounds.y + Math.max(0, (screenBounds.height - ph) / 2 );
rect.height = Math.min(screenBounds.height, ph);
}
}
return rect;
} Same method on Java 8: /**
* Calculate the placement and size of the popup portion of the combo box based
* on the combo box location and the enclosing screen bounds. If
* no transformations are required, then the returned rectangle will
* have the same values as the parameters.
*
* @param px starting x location
* @param py starting y location
* @param pw starting width
* @param ph starting height
* @return a rectangle which represents the placement and size of the popup
*/
protected Rectangle computePopupBounds(int px,int py,int pw,int ph) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds;
// Calculate the desktop dimensions relative to the combo box.
GraphicsConfiguration gc = comboBox.getGraphicsConfiguration();
Point p = new Point();
SwingUtilities.convertPointFromScreen(p, comboBox);
if (gc != null) {
Insets screenInsets = toolkit.getScreenInsets(gc);
screenBounds = gc.getBounds();
screenBounds.width -= (screenInsets.left + screenInsets.right);
screenBounds.height -= (screenInsets.top + screenInsets.bottom);
screenBounds.x += (p.x + screenInsets.left);
screenBounds.y += (p.y + screenInsets.top);
}
else {
screenBounds = new Rectangle(p, toolkit.getScreenSize());
}
Rectangle rect = new Rectangle(px,py,pw,ph);
if (py+ph > screenBounds.y+screenBounds.height
&& ph < screenBounds.height) {
rect.y = -rect.height;
}
return rect;
} They try to account for popup border in a really weird way which is kinda fine for small borders, but in case of WebLaF large visual border it causes the bug mentioned in the first post. I'll probably replace this part of code with Java 8 implementation and test it to see if it has any side-effects or not. |
I've added a fix for this issue, it will be available in v1.2.13 update. |
I also updated current |
Combobox popup has a large offset when displayed at north side:
Same issue happens with lightweight & heavyweight popup and also does not change on different OS versions, but it only appears on Java 9+.
The text was updated successfully, but these errors were encountered: