You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered a StackOverflow error when showing a JOptionPane by passing a String to the message parameter of javax.swing.JOptionPane#showConfirmDialog(java.awt.Component, java.lang.Object, java.lang.String, int, int), which should wrap the message in a JLabel component internally.
Unfortunately, I don't have a snippet to help reproduce it; I have the stack trace.
P.S. I've managed to workaround the issue by passing JLabel to message parameter rather than passing a String.
Stack trace:
[AWT-EventQueue-0] ERROR my.app.Application - Uncaught exception occurred java.lang.StackOverflowError: null
at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:243)
at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:686)
at java.base/java.lang.StringBuffer.append(StringBuffer.java:393)
at java.base/java.io.StringWriter.write(StringWriter.java:122)
at java.base/java.io.PrintWriter.implWrite(PrintWriter.java:621)
at java.base/java.io.PrintWriter.write(PrintWriter.java:613)
at java.base/java.io.PrintWriter.write(PrintWriter.java:635)
at java.base/java.io.PrintWriter.print(PrintWriter.java:782)
at java.base/java.io.PrintWriter.println(PrintWriter.java:1033)
at java.base/java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:801)
at java.base/java.lang.Throwable.lockedPrintStackTrace(Throwable.java:684)
at java.base/java.lang.Throwable.printStackTrace(Throwable.java:673)
at java.base/java.lang.Throwable.printStackTrace(Throwable.java:749)
at java.desktop/javax.swing.UIDefaults.getUI(UIDefaults.java:816)
at java.desktop/javax.swing.UIManager.getUI(UIManager.java:1070)
at java.desktop/javax.swing.JPanel.updateUI(JPanel.java:129)
at java.desktop/javax.swing.JPanel.<init>(JPanel.java:89)
at java.desktop/javax.swing.JPanel.<init>(JPanel.java:112)
at java.desktop/javax.swing.JPanel.<init>(JPanel.java:120)
at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI$1.<init>(BasicOptionPaneUI.java:486)
at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.addMessageComponents(BasicOptionPaneUI.java:486)
at com.formdev.flatlaf.ui.FlatOptionPaneUI.addMessageComponents(FlatOptionPaneUI.java:220)
at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.addMessageComponents(BasicOptionPaneUI.java:512)
at com.formdev.flatlaf.ui.FlatOptionPaneUI.addMessageComponents(FlatOptionPaneUI.java:220)
at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.addMessageComponents(BasicOptionPaneUI.java:512)
at com.formdev.flatlaf.ui.FlatOptionPaneUI.addMessageComponents(FlatOptionPaneUI.java:220)
at java.desktop/javax.swing.plaf.basic.BasicOptionPaneUI.addMessageComponents(BasicOptionPaneUI.java:512)
// recursive calls to the last two frames...
Probably it has something to do with the message string content.
Could you provide that string?
If you don't want to post it here, please send it to [email protected]
It's a really strange case because the strings are nothing special ex. "Exit Application".
I'll happily contribute the fix if I figure it out when this happens again.
This isn't a common issue for sure.
I think it has something to do with (larger?) multi-line message strings (that contain \n).
BasicOptionPaneUI.addMessageComponents() splits multi-line message and invokes itself with substrings...
But normally this does not result in stack overflow...
I've encountered a StackOverflow error when showing a JOptionPane by passing a String to the
message
parameter ofjavax.swing.JOptionPane#showConfirmDialog(java.awt.Component, java.lang.Object, java.lang.String, int, int)
, which should wrap the message in a JLabel component internally.Unfortunately, I don't have a snippet to help reproduce it; I have the stack trace.
P.S. I've managed to workaround the issue by passing
JLabel
tomessage
parameter rather than passing aString
.Stack trace:
Java: 22.0.1 Oracle Corporation
OS: macOS 15.3 (24D60)
The text was updated successfully, but these errors were encountered: