Skip to content

Commit 35bc313

Browse files
committed
CayenneModeler .. Messy combo box sizing for editable popups
fixing an issue on windows
1 parent a6e2c67 commit 35bc313

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/toolkit/table/CMComboBoxCellEditor.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,21 @@ public CMComboBoxCellEditor(JComboBox<?> comboBox) {
6262
comboBox.addPopupMenuListener(new PopupMenuListener() {
6363
@Override
6464
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
65+
// First call: sets popup.preferredSize so the popup *window* is created at the
66+
// correct width (window size is determined from popup.preferredSize before show()).
6567
adjustPopupWidth();
68+
// Second call via invokeLater: BasicComboPopup.show() calls getPopupLocation()
69+
// *after* firing this listener, which re-constrains scroller.maxSize back to the
70+
// column width. Running again on the next EDT cycle fixes the scroller, then
71+
// revalidate/repaint forces the layout to update inside the already-wide window.
72+
SwingUtilities.invokeLater(() -> {
73+
adjustPopupWidth();
74+
Object child = comboBox.getUI().getAccessibleChild(comboBox, 0);
75+
if (child instanceof JPopupMenu popup) {
76+
popup.revalidate();
77+
popup.repaint();
78+
}
79+
});
6680
}
6781
@Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
6882
@Override public void popupMenuCanceled(PopupMenuEvent e) {}

0 commit comments

Comments
 (0)