{"record":{"id":"c8fa5ad48bbe1620","repo":"JetBrains/intellij-community","slug":"unexpected-element-element","errorCode":null,"errorMessage":"unexpected element: {element}","messagePattern":"unexpected element: (.+?)","errorType":"exception","errorClass":"UnexpectedFormElementException","httpStatus":null,"severity":"error","filePath":"java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwContainer.java","lineNumber":288,"sourceCode":"    }\n    else if(UIFormXmlConstants.ELEMENT_SCROLLPANE.equals(name)) {\n      String className = LwXmlReader.getOptionalString(child, UIFormXmlConstants.ATTRIBUTE_CLASS, \"javax.swing.JScrollPane\");\n      component = new LwScrollPane(className);\n    }\n    else if(UIFormXmlConstants.ELEMENT_TABBEDPANE.equals(name)){\n      String className = LwXmlReader.getOptionalString(child, UIFormXmlConstants.ATTRIBUTE_CLASS, \"javax.swing.JTabbedPane\");\n      component = new LwTabbedPane(className);\n    }\n    else if(UIFormXmlConstants.ELEMENT_SPLITPANE.equals(name)){\n      String className = LwXmlReader.getOptionalString(child, UIFormXmlConstants.ATTRIBUTE_CLASS, \"javax.swing.JSplitPane\");\n      component = new LwSplitPane(className);\n    }\n    else if (UIFormXmlConstants.ELEMENT_TOOLBAR.equals(name)) {\n      String className = LwXmlReader.getOptionalString(child, UIFormXmlConstants.ATTRIBUTE_CLASS, \"javax.swing.JToolBar\");\n      component = new LwToolBar(className);\n    }\n    else{\n      throw new UnexpectedFormElementException(\"unexpected element: \"+child);\n    }\n    return component;\n  }\n\n  /**\n   * 'xy' or 'grid'\n   */\n  protected final void readLayout(final Element element){\n    myLayoutManager = element.getAttributeValue(\"layout-manager\");\n    if(\"xy\".equals(element.getName())){\n      myLayoutSerializer = XYLayoutSerializer.INSTANCE;\n    }\n    else if(\"grid\".equals(element.getName())){\n      createLayoutSerializer();\n    }\n    else{\n      throw new UnexpectedFormElementException(\"unexpected element: \"+element);\n    }","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwContainer.java#L270-L306","documentation":"Thrown by LwContainer.createComponent (via the createComponent factory in LwContainer) while parsing a form's XML: a child element inside a container matched none of the recognized component element names (component types like tabbed-pane, split-pane, toolbar, and their siblings). UnexpectedFormElementException signals that the .form XML contains an element the lightweight form reader does not know how to turn into an LwComponent.","triggerScenarios":"Parsing a .form file where a container element has a child whose tag is not in the known set — e.g. a typo'd or newer-version tag such as 'tabbedpane' instead of 'tabbed-pane', or an element introduced by a newer IDE format being read by an older forms-compiler. The else branch throws UnexpectedFormElementException with the offending element toString.","commonSituations":"Form files created by a newer IntelliJ version using new component tags, then opened/compiled by an older forms-compiler; hand-edited form XML with mistyped element names; third-party tools generating non-conforming form XML.","solutions":["Open the .form file and inspect the element printed in the message; correct the tag name to the expected kebab-case element (e.g. 'tabbed-pane', 'split-pane', 'toolbar').","If the form came from a newer IDE, upgrade the forms-compiler/IDE reading it so the new element names are recognized.","Regenerate the form in the GUI designer instead of hand-editing the XML.","Delete the unrecognized element from the form if the component is not needed."],"exampleFix":"<!-- before -->\n<tabbedpane binding=\"myTabs\"> ... </tabbedpane>\n\n<!-- after -->\n<tabbed-pane binding=\"myTabs\"> ... </tabbed-pane>","handlingStrategy":"validation","validationCode":"// When generating form XML, whitelist container children before writing\nSet<String> KNOWN = Set.of(\"component\", \"grid\", \"xy\", \"tabbed-pane\", \"split-pane\", \"toolbar\");\nif (!KNOWN.contains(childTagName)) throw new IllegalArgumentException(\"Unknown form element: \" + childTagName);","typeGuard":null,"tryCatchPattern":"try { Utils.loadFormXml(stream); } catch (UnexpectedFormElementException e) { /* message prints the offending element; fix or remove that tag in the .form file */ }","preventionTips":["Only edit form XML with the GUI designer, never by hand, for structural changes.","Keep the forms-compiler/IDE version at least as new as the IDE that authored the forms.","Validate generated form XML against a designer-produced sample."],"tags":["gui-designer","form-xml","xml-parse","unexpected-element"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}