mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-09 08:15:09 +03:00
ComboBox: limit popup width to screen width for very long items (issue #182)
This commit is contained in:
@@ -19,6 +19,7 @@ FlatLaf Change Log
|
|||||||
|
|
||||||
- ComboBox: If using own `JTextField` as editor, default text field border is
|
- ComboBox: If using own `JTextField` as editor, default text field border is
|
||||||
now removed to avoid duplicate border.
|
now removed to avoid duplicate border.
|
||||||
|
- ComboBox: Limit popup width to screen width for very long items. (issue #182)
|
||||||
- FileChooser: Fixed localizing special Windows folders (e.g. "Documents") and
|
- FileChooser: Fixed localizing special Windows folders (e.g. "Documents") and
|
||||||
enabled hiding known file extensions (if enabled in Windows Explorer). (issue
|
enabled hiding known file extensions (if enabled in Windows Explorer). (issue
|
||||||
#178)
|
#178)
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ import java.awt.Container;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.LayoutManager;
|
import java.awt.LayoutManager;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
@@ -567,6 +569,17 @@ public class FlatComboBoxUI
|
|||||||
|
|
||||||
// make popup wider if necessary
|
// make popup wider if necessary
|
||||||
if( displayWidth > pw ) {
|
if( displayWidth > pw ) {
|
||||||
|
// limit popup width to screen width
|
||||||
|
GraphicsConfiguration gc = comboBox.getGraphicsConfiguration();
|
||||||
|
if( gc != null ) {
|
||||||
|
Rectangle screenBounds = gc.getBounds();
|
||||||
|
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
||||||
|
displayWidth = Math.min( displayWidth, screenBounds.width - screenInsets.left - screenInsets.right );
|
||||||
|
} else {
|
||||||
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
displayWidth = Math.min( displayWidth, screenSize.width );
|
||||||
|
}
|
||||||
|
|
||||||
int diff = displayWidth - pw;
|
int diff = displayWidth - pw;
|
||||||
pw = displayWidth;
|
pw = displayWidth;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user