0

Similar questions has been asked but no good answers and nothing that worked for me (1, 2, 3).

In my Maven's project, I'm using IntelliJ IDEA's UI designer and every once in a while I'm getting (maybe it have something to do with me running maven clean & install)

"contentPane cannot be set to null."

To fix it I simply change the panel name using the UI designer, but this solution is not good for running a jar made of my code, and I'm trying to understand the problem and find a more permanent solution.

As you can see below, I haven't checked the "Custom Create" box, and as far as I know, it means that the designer is automatically initializing it (otherwise renaming the panel won't fix it).

swing frame

public class MyFrame extends JDialog {
    private JPanel contentPanel;
    .
    .
    .

    private MyFrame() {
        setContentPane(contentPanel);
        .
        .

    }

pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>app.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>ideauidesigner-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>javac2</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <fork>true</fork>
                    <debug>true</debug>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>
.
.
.
</build>

Component Tree

enter image description here

Kfir Ettinger
  • 584
  • 4
  • 13
  • If possible please prepare and provide a small project sample here https://youtrack.jetbrains.com/issue/IDEA-191465 . What build system do you use? – Egor Klepikov Sep 20 '22 at 10:45
  • the build system I use is `maven` and I can show you a sample code but it happening in all of my frames and they are pretty basic so I don't think it will help – Kfir Ettinger Sep 20 '22 at 10:58
  • @EgorKlepikov do you think "maven clean" may cause this? – Kfir Ettinger Sep 20 '22 at 11:32

0 Answers0