mbien commented on code in PR #6577:
URL: https://github.com/apache/netbeans/pull/6577#discussion_r1545791853


##########
platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java:
##########
@@ -494,29 +490,23 @@ public int getMaxCharactersPerLineCount() {
         } else {
             //Do not override JOptionPane.getMaxCharactersPerLineCount for 
html text
             optionPane = new JOptionPane(
-            msg,
-            descriptor.getMessageType(),
-            0, // options type
-            null, // icon
-            new Object[0], // options
-            null // value
+                msg,
+                descriptor.getMessageType(),
+                0, // options type
+                null, // icon
+                new Object[0], // options
+                null // value
             );
         }
 
-        if (UIManager.getLookAndFeel().getClass() == MetalLookAndFeel.class ||
-            UIManager.getLookAndFeel().getClass() == BasicLookAndFeel.class) {
-            optionPane.setUI(new javax.swing.plaf.basic.BasicOptionPaneUI() {
-                @Override
-                public Dimension getMinimumOptionPaneSize() {
-                    if (minimumSize == null) {
-                        //minimumSize = 
UIManager.getDimension("OptionPane.minimumSize");
-                        // this is called before defaults initialized?!!!
-                        return new Dimension(MinimumWidth, 50);
-                    }
-                    return new Dimension(minimumSize.width, 50);
-                }
-            });
+        // javax.swing.plaf.basic.BasicOptionPaneUI uses hardcoded min height 
of 90,
+        // if no other default is set. Min height should be about the size of 
the
+        // used icon, so that dialogs with single-line messages can size 
themself properly.
+        Dimension minSize = UIManager.getDimension("OptionPane.minimumSize");
+        if (minSize != null) {
+            minSize.setSize(minSize.getWidth(), 38);
         }

Review Comment:
   it remains a little bit of a mystery to me why this doesn't have to be set 
outside of NB when `JOptionPane.showOptionDialog` is used, despite the property 
having the exact same value (added a screenshot to 
https://github.com/apache/netbeans/pull/6577#issuecomment-2028812444 showing 
the stock dialog). 
   
   My guess is that the layout manager is different and one ignores min size 
the other does not. JDK doesn't do anything special here, it calls pack too:
   
https://github.com/openjdk/jdk/blob/9d052e93314f7fa50b356e368faa5ea723d3df54/src/java.desktop/share/classes/javax/swing/JOptionPane.java#L987-L998
   
   But I am not planning to investigate this further for now unless it is 
causing problems.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to