Swing UI elements not initialized
已回答
Hello,
in my plugin I'm using some forms (f.e. for Language settings) created by Intellij
RMB -> New -> Swing UI Designer -> Create Dialog Class
But that generated component in some cases fails that elements are null -> it seems that when developing a plugin (running gradle runIde) all is ok, but once released and installed from marketplace it fails:
java.awt.IllegalComponentStateException: contentPane cannot be set to null. at java.desktop/javax.swing.JRootPane.setContentPane(JRootPane.java:594) at java.desktop/javax.swing.JDialog.setContentPane(JDialog.java:1036) at gdscript.settings.GdDownloadSdk.<init>(GdDownloadSdk.java:24) at gdscript.settings.component.GdSettingsComponents.addSdk$lambda$3(GdSettingsComponents.kt:65) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262) at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374) at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1028) at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1072) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6656) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385) at java.desktop/java.awt.Component.processEvent(Component.java:6421)
...
How are those components supposed to be initialized?
请先登录再写评论。
P.S. I've tried to change gradle build to IntelliJ as writtent at the end of:
https://www.jetbrains.com/help/idea/work-with-gradle-projects.html#delegate_build_gradle
But no luck... or does it not affect builds run with gradle configuration?
Ok I've found it.
Not sure why it worked when runned for development, but 'Ive been missing main method inside form class and even found out that maybe I've been building it wrong and should call buildPlugin instead of just build
Hey, can your maybe show your (exameple) code. I have the same problem, but dont have any solutions
Hi, if I remember correctly, it was following class (shortened version)
And problem was solved by adding
public static void main(String[] args)for whatever reason.Have no idea why it was required and I no longer use it for months, but was probably due to something trying to test that class so it was looking for main method?
That's strange, I have it 1:1 exactly the same but it doesn't work for me. how do you open the dialogue? Thanks for your help
I can't get rid of this error.
java.awt.IllegalComponentStateException: contentPane cannot be set to null.It's not the whole code, contentPane should be initialized at
I just can't get any further, maybe you can look over our code